Use subject-verb inversion and do-support with main clauses which ask questions (unless questioning the subject, of course).
Do not use inversion with the corresponding subordinate clauses (indirect questions).
Who was he? / Nobody knows who he was.
What did you put on the shelf? / I don't...