Across the ages: (I do this with both my 3.5 year old son when he's being too rough with my body, because we don't really have a 'disrespect' issue in our home, and even with older children)
Some things to point out:
"Wow. I really don't like what you said/how you are talking to me."
"Oh. Do you see Daddy's face? How does he look? He looks upset. He doesn't like what you said/how you are talking to him."
and then " Let's try it again-- what do you want to tell him/her? All right, let's try that in a friendly way now." and help them find a more appropriate way to state their feelings.
Mouthy, older children need a bit more of a firm hand. "People are for speaking to, not for yelling/being rude to." I speak to children myself without sarcasm and try not to give snippy answers, so I expect the same from them. If the child can't pull themselves out of their attitude, I try to give them context. "I see that you aren't ready to be pleasant right now. The place to be disagreeable is your room. Please stay in there until you are ready to be friendly/ solve the problem in a friendly way."
If they are grumbling about having to do something I've asked, most of the time I let it go and just ignore it, so long as they are getting the task done. If not, they can go spend some time in their room, or they may sit on a chair until they are ready to follow directions. It all depends on the situation; some kids are grumpy/sassy because they do need a break from the activity of the day (esp. if they haven't had much downtime). Other kids are just being a pill, some days, and trying to get some attention for this mouthing off. I try to address what's behind each incident before deciding how I will handle it.
I still remember two mouthy 9 year olds who, when asked a question, rolled their eyes in unison and said "Whatever!" They were a little surprised when I explained to them that I'd given them a choice, and since they'd replied "whatever", it meant that I could choose what *I* liked. That significantly decreased the usage of that word for a while. Fortunately, too, they grew out of it.
The book "How to talk so kids will listen...and how to listen so kids will talk" by Faber and Mazlish can also be a big help in this area. Required reading for every parent, in my opinion, because this book is wonderful!
Good luck and lots of patience,
H.