You could argue they are all grammatically correct. You could argue the punctuation is appropriate as it is.
Some people would say stronger punctuation is needed, for clarity, especially for phrases 2 & 3; but I would counter that by saying the addition of extra punctuation would produce a potentially undesirable change in tone and potentially even a slight change in context.
Personally, if writing for my own website for example, I would probably favour the double comma structure, for slightly increased clarity, since it also remains very open, so has minimal affect on tone:
2. If he knew it, he would do, I don't know what.
3. If he knew it, what he would do, I don't know.
But if writing to impress an examiner, or writing for translation into another language, I would probably add much stricter punctuation, using a colon, for much more specific context, and suffer the slight change in tone, like this:
2. If he knew it, he would do: I don't know what.
3. If he knew it: what he would do, I don't know.