The advice below is great because I used them all and most of the worked with most of my kids. However none of these worked with my son and I had to resort to either flicking his cheek to make him aware of what he was doing and after a couple of times I would just say "You are whining do you need a flick" His immediate response would be no and he would stop. Now before everybody gets all worked up over the flicking, at most it is just shocking to the child and until you have a kid that you have tried everything with, including the popping on the mouth, you have no idea how frustrating it can be. Boys are always more persistent than girls and so you have to take that into consideration as well. The other thing that has worked really well for my family and many others I know is a spray bottle filled with Apple Cider vinegar that gets sprayed in their mouth when they are sassy or whiny. It is sour and kids really don't like sour things. I also used the same technique with this one (worked better with my girls). I explained what was going to happen, followed through and then the next time would ask if that was what they wanted and usually they said no and stopped the behavior. Kids aren't perfect and there is no instruction manual, so my biggest suggestion is to try everything and find the thing that works for your child..
A little about me: SAHM of four kids ages 13, 10, 8, and 6. I am 36 years old and have been happily married for the last 15 years...