If your child is younger, simply ask, "How do you ask nicely?" Reminding her of this will help get her out of the bad habit of always whining when she wants something.
If your child is older, address the whining by asking her how she can change the way she is speaking. By turning it into a learning experience, your child will begin realize when she is whining and will begin to change her habit.
When your child starts to whine, say something along the lines of "I will listen when you speak to me calmly," and follow through with what you say. Although it may take some practice and patience, your child will eventually learn to use a calm and rational voice when she needs or wants something.
The same goes for older children and teens. If your teen approaches you in a mature manner about something she needs or wants, responding positively will help keep this trend going.