Choosing between who and whom, either as a relative pronoun or question word, can be tricky for English language learners and native speakers of English alike.
The quick test in choosing between who and whom is to substitute he or him. If he sounds better, who is correct; if him sounds right, whom is correct. That’s because as a pronoun whom is used to represent the object of either a verb or a preposition, while who represents the subject of a verb.
He is the consultant whom we contacted for advice. (We contacted him.)
To whom was the letter addressed? (The letter was addressed to him.)
He is the consultant who can answer your question. (He can answer your question.)
Increasingly, native speakers of English are adopting who as the preferred pronoun in informal conversation, even when whom, not who, is correct. This means that whom, when correctly used as an object pronoun, can sound more formal.
In the two examples above, the formality can be toned down by omitting the pronoun in the first, and using the more casual who in the second:
He is the consultant we contacted for advice.
Who was the letter addressed to?
Who did you go to the movies with? is technically incorrect but very common, even for speakers who are well aware of the mistake.
With whom did you go to the movies? is correct but in an informal conversation can stand out as having a bit more formal tone.
The he/him test works well unless you’re confronted with a choice between whoever and whomever as in this sentence:
You can just talk with whoever/whomever answers the phone.
Even native English speakers get confused by this, because our instinct tells us that whom, not who, should follow the preposition with. However, there is another rule in English which dictates that every verb in a tense needs a subject. Here, whoever is the correct choice, since the verb answers needs a subject.
Striking a more formal, educated tone doesn’t have to be the only reason to use whom as the object pronoun. Sometimes it’s an elegant way to emphasize a distinction between subject and object. If you see someone walking a dog, and the dog is so big and strong that it’s all its owner can do to keep up with it, you can ask, Who is walking whom?