This is a classical dilemma. Which one is correct? Fortunately, it’s hard to make a mistake here because both “gut deutsch sprechen” and “gutes Deutsch sprechen” are correct. Notice, however, that the “d” in the first expression is small whereas in the second one it is capitalized.
The reason is that “er spricht gut deutsch” means “he speaks German well” where both “gut” and “deutsch” are used as adverbs. In “er spricht gutes Deutsch”, “Deutsch” is a noun and “gutes” is an adjective, so it literally means “he speaks good German”.