What didn't Tom do? : This question says Tom has done everything basically so what is left for him to do that he has not already done. So, Tom did not do what? What didn't he complete?
What didn't do Tom? : This sentence is incorrect. The verb "do" should come after Tom.
Hope this helps! Contact me for more English lessons. I'd be happy to help! :)