This portion of a sentence is an example what literary term and he asked me where Moses was when the candle went out?
The portion of the sentence "and he asked me where Moses was when the candle went out?" is an example of a riddle.
It's a play on words, as it sounds like a straightforward question about a historical figure, but it's actually a trick question designed to make the listener think about the phrase "where Moses was". The answer, of course, is "In the dark".