Proper placement of "exactly"?
Solution 1:
None, in my opinion, for the meaning you provided.
- (How exactly) does X work? = What is the precision of X? (compare: How loudly can this speaker play?)
- How does (exactly X) work? = Why is precisely X effective, but if you modify X by a small detail it stops working? (compare: Why do we have exactly thirty-two teeth?)
- ?How does X exactly work? - I do not think this would be correct, but I'm willing to be proven wrong.
- How does X (work exactly)? = What is the mechanism by which X is given the ability to be exact? (compare: How do you close that door quietly? I've never managed it...)
And the two (three?) correct ones:
- How, exactly, does X work? = What is the exact mechanism by which X works?
- How does X work, exactly? - Same
- Exactly how does X work? - Not 100% sure about this one, but I'll go out on a limb and say I find it's fine
Of course, eliding the commas is common, so I'd vote the first and the fourth of your examples as the closest ones.
The reason I have trouble with the third one is the fact that "exactly", while undoubtedly an adverb, does not modify "work". It makes no sense for it to modify "work". The paraphrase for the original question would likely be "Please explain to me exactly how X works", and in this paraphrase it is clear that "exactly" modifies "explain". The fact that "Please explain to me" has been elided in the sentence while keeping the same meaning should not suddenly be able to shift the attachment of this adverb. This goes well with the fact (at least fact in the way I perceive it) that "exactly" is kept apart from the sentence by the commas.
Also, pet peeve: I hate the word "adverb". It is useless and misleading. Adverbs are modifiers that are not nouns or adjectives. They can certainly modify things that are not verbs, such as other adverbs ("very quickly"), adjectives ("reasonably pretty")...