Rule: All pronouns must agree in number and gender with their antecedents (an antecedent is the noun a pronoun replaces).
Note: Here at Conventions of Composition headquarters, we believe that people can decide what personal pronouns suit them. If you have a hard time thinking of a singular, specific person as they, you might want to read this piece by Grammar Girl.
Note: "Body" words (anybody, somebody, nobody, everybody), "one" words (anyone, someone, no one, everyone), each, either, and neither are singular. They require singular verbs; pronouns referring to them must be singular. Each other is ordinarily used of two, and one another of three or more.
Examples:
Wrong: When my son sees this word, she notices its humor.
Correct: When my son sees this word, he notices its humor.
Correct: Author Alex Gino creates a realistic situation in their novel, George.
Grammatically correct, but sexist: Everybody raised his hat.
Better: All raised their hats.
Grammatically correct, but sexist: Each attacked the other; each defended himself.
Correct: Both attacked and defended themselves.
Wrong: A person should pick up the remains when you walk your dog.
Grammatically correct, but sexist: A person should pick up the remains when he walks his dog.
Better: You should pick up the remains when you walk your dog.
Also better: People should pick up the remains when they walk their dogs.
Practice creating pronoun-antecedent agreement in the following sentences:
A girl who loves grammar left their book in the classroom by mistake.
Each boy on that team worked their hardest to win the final game.
Every man, woman, and child wanted to know their place in line.
Resources for further explanation of pronoun-antecedent agreement:
Web Apps' Pronoun-Antecedent Agreement
English Grammar 101's Pronoun Agreement