I wondered what the children were doing while/when I was out.
I think most people will prefer using "while" in this sentence, though it's also correct to use "when" in the sentence.
Grammatically speaking, while and when are interchangeable where it means
"during the time that something else happens". "When" also refers to "a point in time". you can't use "while" in place of "when" in this case. For example, when he called, I went to him immediately. It's incorrect to say "while he called, I went to him immediately".
It's also not correct to say that we use "while" only in the -ing form of a verb. For example, someone called while you were out (Macmillan), his parents died while he was still in school, we were burgled while we were asleep (OLD), etc.