It's a real milestone when our children get to the age that they can make us laugh by what they say on purpose! Often with smaller children we laugh at what they say by accident, and they are pleased but uncertain about what was funny and why. As children get to older elementary school they learn skills and life lessons that they turn into humor.
Often older kids and teens emulate adults and use sarcasm to make a joke, or make a point. This is a valuable skill and shouldn't be squashed. Neither should we let it run rampant over conversations and people!
It's important to show a teen that you value his humor and intelligence but want him to learn when this is and is not appropriate to use. Many 'tweens and teens try out sarcasm and some have a real flair for it! Also, it may be part of acceptable joking around behavior in your family.
Like any edgy conversation (teasing, joking, even swearing), teens need to learn when and when NOT to engage. He may use sarcasm really successfully with friends and to good effect, but needs to know to leave it in the hallway at school or he could have some big trouble.
With any teenage behavior change, it works better to be very clear about the goal. First talk to your partner. Is it OK with both of you that he practices sarcasm at home sometimes? Hash this out just grownups first. You may decide he is not mature enough yet to use this only on the "right" occasions so you want him to stop (in your hearing) all the time. Remember that he is unlikely to stop entirely. You will teach him important life lessons if you choose to guide him about when to use this, instead of forbidding the behavior entirely.
Now sit with him for a few minutes (and your co-parent if possible) and tell him that you really appreciate his humor and smarts but need to teach him the skill of when it is and isn't ok to use sarcasm when speaking to an adult. Decide (with your teen's help) on a nonverbal cue that you can use if he is being smart-alecky instead of smart, like a hand on his arm or (if he isn't a toucher right now) grabbing your own ear lobe for a minute. Then he has the opportunity for a conversational do-over, meaning he can express the same idea but more respectfully. If he can start again without the edge in his words or voice, you'll continue the conversation as if nothing happened.
When you are talking to him about this, be clear with him what the consequence will be if he does not take the do-over chance but continues to be disrespectful. You may automatically deny his request if he can't speak respectfully. He may miss his next social outing. He may be excused from the table even if he is still hungry (this one really bothers teen boys!).
In this way you are not stepping on his creativity and humor, but you are requiring respectful communication and helping him learn how and when he can joke. Also, he has the chance to be a good example for any younger sister or brother so that you don't hear smart-alecky teenage stuff from the mouths of babes!