If you can answer the question with a "he" or "she," use "who" in the sentence.
Question: Who threw the pencil at me?
Answer: He threw the pencil at me.
Create a question in your mind out of a "who" sentence.
Sentence: Who loves to read the newspaper?
In your mind think: Who loves to read? She loves to read. The conclusion is "who" is correct.
If you an answer the question with a "her" or "him," use "whom" in the sentence.
Question: To whom are you talking?
Answer: I am talking to her.
Create a question in your mind out of a "whom" sentence.
Statement: He only invited girls to the party whom he found attractive.
In your mind, create a question and the answer: Whom did he invite? He invited her to the party.