Prevent inappropriate remarks from happening in the first place, by setting clear expectations at the beginning of the year. Educate your students about the effects that sexist, racist, homophobic or similar offensive comments can have on other students. Remind them that your classroom is an inclusive, public space where no one should feel intimidated or unwelcome.
Discuss the issue with the entire class when a student makes an inappropriate comment. Avoid singling out the student and embarrassing him in front of the class, as this might cause resentment and lead to further comments. Inform the class and have them discuss why offensive language should offend us all, even if no member of the comment's target group is in the class.
Talk privately with the student if you feel the situation warrants it. Explain why his comments are offensive and why they hinder the participation of other students in the class. Tell him that inappropriate remarks also interrupt the lesson and the learning process, which is unfair to everyone in the class. Make it clear that you don't want to hear those kinds of remarks again.
Contact the student's parents, if the inappropriate remarks persist. Explain to the parents why such language cannot be tolerated in the classroom. Come to a solution together as to how you can get through to the student.