Sarcasm is a great way to diffuse a negative emotion, but it's easy to go overboard. The Wall Street Journal suggests you stick to only using sarcasm when you're close with someone to avoid potential confusion.
It's probably a little obvious that you should only use sarcasm when you're comfortable with a person, but the real point here is sarcasm's best kept for personal relationships because it's generally an expression that helps you bond with people. The Wall Street Journal explains:
So how do you deal with sarcasm? Dr. Kreuz says to remember that if someone is being sarcastic to you, he or she may be showing a form of affection. He suggests saying something gently sarcastic back, to show you understand the exchange. If you are the one who likes to be sarcastic, don't do it with strangers — they are less likely to understand your intent... As an adult, [Mr. Laermer] says he uses sarcasm to accomplish several things: To bond with people; push them to lighten up and not take life too seriously; and to remind them of their actions."
So think twice before you drop that snarky comment on your new boss, the worker at the cafe or on that first date. It has plenty of great uses, but save for them for when the relationship is a bit more developed.
People Love Your Sarcasm, Really [The Wall Street Journal]