People frequently want to know what to do if they feel they're being illegally harassed at work, or if they think that they're about to get fired for an illegal reason. The answer depends on what your goal is, and what your particular situation is like.
First of all, remember that most types of workplace harassment are not illegal. Harassment is only illegal if it's based on a protected characteristic, like race, age, sex, religion, disability, or a handful of others. If you're being harassed at work, but it's not because of a protected characteristic (and you're not in a union), you probably have no legal recourse at all. Consider trying to address the problem internally, either with the person harassing you, that person's supervisor, or with human resources. Remember, though, that your complaints of legal, but harassing, activity can get you fired, and again, there's no legal recourse for that. So consider carefully whether what you're experiencing is something you can live with, or if you feel the need to do something about it at the risk of experiencing retaliation without recourse for you.
So let's assume for the moment that you feel you're being illegally harassed because of a protected characteristic, or that you think you're about to get fired for an illegal reason. What do you do about it?
My best advice is: Do what you can to address the situation, while keeping your job and avoiding a lawsuit. Sometimes that means looking for another place to work, and not saying anything until you've found one. Even if it's not the best thing for having a lawsuit later, the odds are good that you'd rather have a job than a lawsuit, especially in a rotten economy.
Look, the people who I help usually have no reasonable options available to them other than filing a lawsuit. They've been fired, or the illegal harassment they've suffered is so extreme that the law needs to address it. The legal system, however, needs to be looked at as a last resort. It's ugly, expensive, time-consuming, and your time and energy would be better spent finding a new job and getting on with your life, if you can manage it.
If you nonetheless feel the need to protect your legal rights, the first thing to do is to buy a journal. In that journal, write every harassing or discriminatory act as it occurs. I don't mean every sideways glance that your supervisor gives you (no one, including juries, likes a complainer), but things that actually affect you economically or extremely outrageous conduct. Don't write anything else in that journal; it may be shown to a jury in the future, so no doodles, no grocery lists, nothing like that. Make sure to take that journal home every night, because they have a way of disappearing when left at the office.
Also in that journal, write everything you remember that happened previously. Don't try to pretend that you're writing it as it happened; make it clear that you're recalling it as well as you can.
Consider making a complaint to the offending person or to that person's supervisor. If you're at this stage, consider making the complain in writing and keeping a copy. It is illegal to retaliate against you for complaining of an illegal act, but employers do illegal things all the time, and you'll want a written record that you actually made the complaint (employers' first line of defense in litigation: "We never got a complaint from that person.")
When I say "consider" doing these things, understand that I'm not telling you to do any of these things because I don't know your precise situation. There's no one answer that fits everyone.
If you feel your job is in jeopardy or you need to protect yourself legally, call an employment attorney immediately. That person will take the time to understand your circumstances, and give you the advice that's best for you.
Making a living is hard enough these days without feeling like your job is at stake. Make sure to protect your rights, do what you can to keep from getting fired, and try hard not to sue anybody. If it comes to that, though, know what you have to do to maximize your chances for coming out on top.