"During the war David was a pilot in the RAF." This sentence looks OK to me, but would there be any reason for or against putting a comma after "war"?
The fashion for the last several decades is to use less and lighter punctuation. As there is no danger of misunderstanding the elements of the sentence without the comma, leaving it out is preferred. If one were to read the short sentence aloud there would be no need for even a short pause.
It is fine with or without it; it's more a case of how you want people to read it.
Personally, I would add it because I prefer the pause between the two main parts of the sentence, "During the war" and "David was a pilot.
It's generally good practice to distinguish between extra information (specifically that this is "during the war"), and the main point of the sentence (that David was an RAF pilot).
"During the war, David was a pilot in the RAF."