1. First and foremost, train yourself to remember that sarcasm is an art. There's a lot of poor art being shoveled upon the world these days. Brush up so you don't contribute.
2. There are lines you should never cross, no matter how funny the other side looks from where you are. Keep it above the belt, and use extreme caution when venturing into the land of "your mama."
3. If you sound really, really smart, you're more likely to receive a hand shake or at worst a scowl, than a left kick to the right shin. So throw in at least two four-syllable words. (Viable choices include "innocuous," "disinterested," "effrontery," "repudiate.")
4. Smile your sweetest smile and put on that "But I'm so small and innocent!" face you used to use when you did something to instigate a fight with your younger brother and you tried to weasel out of punishment when he told on you.
5. If you actually do accidentally insult someone (or his mama), refrain from using sarcasm in your apology. It just makes things worse. If you cannot or will not follow Step #5, continue to #6.
6. Sidestep to either the right or the left quickly. Try ducking simultaneously if you don't anticipate a left kick to the right shin.