I apologize in advance for all of the generalizations.
The knowing offender. There are two categories of knowing offenders. The first is one who is an ***hole. This person wants to offend you and has found a way. It is quite likely that you are just as offended by the fact that they are trying to offend you as by what they actually said. I would suggest giving this person a really sarcastic look, shake your head, and laugh. That makes it pretty clear that all people present know that whatever they said was stupid and inappropriate. If that is not enough, end the situation by removing yourself from it.
The other type of knowing offender is someone who feels they need to tell you something important even if they know it will offend you. This is usually something for your own good, so even if it hurts you, it is a good idea to recognize that this person is probably a better friend than you thought. It's a good idea to admit to yourself that this person is really trying to help you rather than hurt you and accept it as such. It is the same idea as someone telling your that there is food in your teeth. You may not like it. You may be embarrassed. However, you are now saved from talking to the cute checker at the grocery store with lunch on display. Thank you, offensive friend. I appreciate your bold ways.
The unknowing offender. There are two kinds of unknowing offenders. The first is one who is offending you and should really know better. This is the person who is cracking paraplegic jokes in front of the guy in the wheelchair. Chances are, he's not trying to be rude. It's just really difficult to see what's going on around you with a severe case of cranial rectosis. Take a deep breath and calmly mention to the person, "So you see the wheelchair, right?" If that isn't enough, and given the situation it may not be, just say, "You're cracking paraplegic jokes in front of the guy in the wheelchair and you should probably stop." This is normally enough. If not, just don't encourage it and move on with your life.
Awesome Tip of the Day: When you feel yourself getting worked up, you are already losing your power of reasoning. This makes it much more difficult for the other person to explain to you that they meant no offense, and much more difficult for you to believe them. It is important in that case to remember that you cannot fight your emotion any more than you can fight fire with fire. You must calm yourself down. Calming your emotion will help you be more receptive to whether a person really is even trying to offend you or what else they could have meant by what they said or did. Once you begin to understand what is actually happening in the situation, it will be easier to diffuse it.
The other unknowing offender has just said something that relates to another thing they could not possibly know about. This is the person who says, "Hey, nice haircut!" and doesn't know that you've been upset all morning because the stylist did the opposite of what you wanted and you hate it. Getting upset with that person will not help. Thank them for their kind gesture and move on. They probably genuinely meant it. People have different tastes and you can't just assume that they feel the same way about it that you do so they should know that it's terrible. If you must, just sigh it off and let them know that you wish it was a nice haircut, because you just spent all morning being upset because the stylist did the opposite of what you wanted and you hate it.
The misinterpreted offender. It is extremely important that you understand that this person did not actually offend you. There are two situations in which this might occur. The first is that you actually misheard what the person said. They said one thing, you heard another. It's as simple as that and you must admit that to yourself and to that person.
Awesome Tip #2: While you're calming yourself down, try to think very clearly and rationally about one important question... "Why would this person say this to me?" Can't believe it? Don't. Unless this person hates you or is otherwise trying to hurt you, chances are they actually did not say whatever it was or at least did not mean it that way. Why would your best friend tell you you're too ugly to go out wearing that? Well, they didn't. Try to go back and think about the actual words that they said and try to take them at face value, without reading into them.
The second situation is that you heard what the person said, but misread what was meant. For example, if you co-worker says to you, "You look tired," and you think they mean that you look bad this morning, you're wrong. Most likely, they're just commenting that you look like you're having a rough day and should take a break. Or it could be that you show the tell-tale signs of a night out and they are looking for a way in to that conversation to hear all about what happened. In other cases, the person is probably also tired and wants to commiserate. None of these are offensive things. These are friendly things. If you keep that in mind, you're less likely to be hurt by what they say.
Final thought on the matter... If you find that you are a relatively sensitive person and the person who is offending you is insensitive, take a moment to understand insensitive people. An insensitive person doesn't not care about how you feel, they just don't understand why you feel that way. Sometimes they don't understand even THAT you feel that way. It is unwise to assume that an insensitive people should "just know" anything, ever. It won't happen. Sensitive people tend to use words and tones to express feelings and emotions. They speak a language that is meant to be interpreted and read into. Deciphering meaning in this language is truly an art. Insensitive people tend to calculate specific words in a specific order and deliver those words to express a specific thought, idea, or observation. This language is meant to be taken exactly how it was delivered. Speaking this language is truly an art.
That said, the person is likely to just repeat for you very clearly the exact words they previously said. If you tell an insensitive person, "You said this, but you meant that," they will disagree with you. They will be upset if you don't remember the words that they carefully chose to deliver to you. Reading into their tone or relating what they said to what that means to you (which they will not have known as mentioned before about assumptions) is effectively the same to an insensitive person as not listening at all. It is like saying, "I don't care what you're really saying. I'm inventing my own meaning and getting offended by it and blaming you." This is highly offensive to an insensitive person! They honestly probably feel bad about offending you, but you can't see it through their frustration. If it continues, and they are smart enough to not try to dig themselves out of the hole, they will likely assume that you are unreasonable and abandon the situation.
The best thing to do is to first calm down and second realize that the person did not mean to offend you. They're probably still unsure even why you're offended because they didn't say anything they could possibly imagine as being a bad thing. Insensitive people tend to make casual, objective observations and comments that they have no emotional attachment to or feeling about one way or the other. Their is no "good" or "bad" label on most things, so they will be completely unaware if you have one. Most insensitive people that I know are just as surprised when they find out that people naturally have this view as an sensitive person is to find out that people live without having that view. Just imagine the amazement between two people, one who has slept in a hammock all his life and never seen a stationary bed, and one who has always had a bed and never seen a hammock. Each has it's advantages but they are such different ways to get the same job done.
Best of luck! Reducing the incidences in which you are offended can greatly reduce the stress in your life and improve your general happiness, especially if you are one to be offended often. Also, if you are either a sensitive or insensitive person looking across that line, maybe this has provided a little insight on what is happening in a situation in which one person is unknowingly offending the other. Talking about it with the wrong approach obviously only makes it worse.