"Which dog is he playing with?" Hvilken hund leker han med?
"Which dog is playing with him?" Hvilken hund leker med ham? But it would sound more natural to include a helper phrase. Hvilken hund er det som leker med ham? Which dog is it that is playing with him? to translate it word by word.
That helper phrase er det som is very common, it makes questions a bit softer and everyday. It's very common in speach but it will often be edited out from publications as it is superfluous.
Who did this = hvem (er det som) har gjort dette? What happened here = hva (er det som) har skjedd her? Which dog is playing with him = hvilken hund (er det som) leker med ham? But it can not be used with when/time (når) and where/place (hvor).
Er det som will almost always be redundant.
For hvilken hund leker han med ? you need to shuffle the order first. Hvilken hund er det (som) han leker med? I put som in parentheses as it sounds more natural without it in this question... I think I am complicating stuff now...
So here's trying a general rule for use: Hva/Hvilken noun/Hvem (er det (som)) (pronoun) verb (preposition). Having a pronoun in the question complicates things, as the word order needs to change to add the helper phrase. That happens because the er (is/are) replaces the original verb (the V2-rule). My apologies if not all of these sound natural in English. Hva (er det som) skjer? What's happening? Hva (er det (som)) du holder på med? What are you doing? Hvilken bil (er det som) skal vaskes? Which car is going to be washed? Hvilke dyr (er det som) er der borte? Which animals are over there? Hvilket hus (er det som) brenner? Which house is burning? Hvem (er det som) kommer? Who is coming? Hvem (er det som) har bestemt det? Who decided that? Hvem (er det (som)) jeg ligner på? Who do I look like?
Further complications: The helper phrase can also be used in past tense/future (var det som). A few of the above : Hvem (var det som) kom (Who came)? Hvilke dyr (var det som) var der borte (Which animals were over there)? Hvem (var det (som)) jeg lignet på (Who did I look like)?
I have a similar question to another one that I've had in this section (Its related to prepositions in English (and it being technically grammatically incorrect to end on prepositions (plus I like the sound prepositions at the beginning))): would it be incorrect to say "Med hvilken hund leker han?"?
It's not incorrect to put prepositions at the end of sentences in English, technically or otherwise. That's some prescriptivist nonsense from grammarians who tried to force English into the mould of Latin and its descendents.
Germanic languages have phrasal verbs and seperable verbs, and having prepositions at the end of sentences is a natural consequence of this.