1. Only then did I understand the problem.

2. Only then I understood the problem.
(Which one is grammatical?)

3. Only after understanding the situation did he make a comment.

4. Only after understanding the situation he made a comment.

5. Only after understanding the situation, did he make a comment.

6. Only after understanding the situation, he made a comment.

(Which ones are grammatical?)

#s 1, 3, and 5 are correct if you remove the comma in 5!

1. Both sentences 1 and 2 are grammatical, but they have slightly different sentence structures.

In sentence 1, "only then" is used as an adverbial phrase, and it is followed by the auxiliary verb "did" and the main verb "understand." This is an example of subject-verb inversion, which is often used in formal or literary writing for emphasis.

In sentence 2, "only then" is also an adverbial phrase, but there is no subject-verb inversion. Instead, the subject "I" comes before the verb "understood." This sentence structure is more common in everyday conversation or informal writing.

Both structures are correct, and the choice between them depends on the desired style or level of formality.

Regarding sentences 3 to 6:

3. "Only after understanding the situation did he make a comment." This sentence is grammatically correct. It follows the same subject-verb inversion pattern as sentence 1, with "only after understanding the situation" as the adverbial phrase.

4. "Only after understanding the situation he made a comment." This sentence is not grammatically correct. It lacks the necessary auxiliary verb to form a complete inversion statement. To make it grammatical, you can use the structure: "Only after understanding the situation did he make a comment."

5. "Only after understanding the situation, did he make a comment." This sentence is also grammatically correct. It is similar to sentence 3, but with a comma added after "situation." The comma helps to indicate a pause and clarify the structure of the sentence.

6. "Only after understanding the situation, he made a comment." This sentence is grammatically correct but has a different structure than sentence 5. The subject "he" comes before the verb "made," and there is no subject-verb inversion. This sentence structure is more common in everyday conversation or informal writing.