When someone says something inappropriate, you may be tempted to lash out or to feel personally threatened. The proper response varies depending on the situation and the exact nature of the comments, but it's important to remain calm. If it's the first time this has happened and it's not specifically directed at you, you may choose to ignore it. If it needs to be addressed, try having a brief, private discussion with your colleague about it.
Check if there's been a misunderstanding, for example, “I thought I heard you say 'x'. Could you explain what you meant by that?” Explain why it made you uncomfortable. If the person is from an older generation, casual racism, sexism and homophobia may be ingrained. While this doesn't make such comments acceptable, they may honestly have not realised their mistake. Cultural differences could also be a reason. For instance, in some cultures, calling someone fat is not seen as offensive.
If this is a repeated issue or if a colleague says something directly to you that's clearly bullying or sexual harassment, you need to bring it to HR or to a supervisor. Plan what you're going to say in advance including specifically what was said, how many if any witnessed it, and how many times the inappropriate behaviour has occurred. Your company should have a policy in place for dealing with these issues.
Whatever the outcome, maintain a professional attitude. If your colleague is disciplined, avoid talking about it. If you find your colleague's conversation consistently unpleasant, but it's not technically an offense, aim to focus on work topics only. Be courteous, but avoid socialising with the person.
Avoid an emotional reaction
Find out if there's a misunderstanding
Consider bringing the issue to HR
Maintain a professional attitude