Every sentence has a subject. The subject is the "doer" of the action described by the verb. Most sentences also have at least one object. An object is something that has the action done to it.
So in this sentence, we have "Mary" as the subject, and "Paul" and "Peter" as objects:
Mary introduced Paul to Peter.
We can replace the subject or either of the objects with an interrogative pronoun: that is, "who" or "whom". (It's a pronoun because it replaces a noun; and it's interrogative because it asks a question.)
Who introduced Paul to Peter?
Here, the interrogative pronoun replaces the subject, so we use "who".
Whom did Mary introduce to Peter?
Whom did Mary introduce Paul to? (Or: To whom did Mary introduce Paul?)
Here, the interrogative pronoun replaces an object in each case, so we use "whom".
"Who" and "whom" can also operate as relative pronouns. Consider these two sentences:
Mary looked at Paul. Paul was talking to Peter.
We can combine the two sentences together, like this:
Mary looked at Paul, who was talking to Peter.
This sentence has two clauses: the main clause "Mary looked at Paul", and the relative clause "who was talking to Peter". In the relative clause, "who" replaces a subject -- it refers to Paul, and Paul is the person doing the talking, so it's the subject, so we use "who".
Mary looked at Peter, whom Paul was talking to.
Now, the pronoun refers to Peter, who, in the relative clause, is not talking, but is being talked to. That makes it the subject, so we use "whom".
This is formal English. But it is becoming more acceptable these days to use "who" instead of "whom". Some purists dislike this trend, so it's best to remember the distinction if you are, for example, writing a job application. But if in doubt, and your English doesn't have to be quite so formal, you can always say "who".