Generations of parents can attest to this and children know it - they whine because it works. It's a great attention-getter because it's proven to be particularly good for annoying parents into giving attention and, if they do it long and often enough and get what they want as a result, then why stop? Most 4-year-olds have it down to a fine art.
Responding with statements such as, "Stop that whining," doesn't get us far as it shows that they're successfully getting under our skin and gaining the attention. Even the reprimand is good payback and, of course, so is, "OK, OK, you can have another biscuit."
The most effective way is to tell them calmly that they're whining, you can't understand what they're saying and could they please repeat whatever it was they said in their normal or "big person" voice.
This has to be done every time as calmly as you can manage so that it appears that it's having no emotional impact on you at all.
"You're big enough now to ask for what you want in a normal voice. If you ask me in a whiny voice my ears will stop hearing you. I'll put my hand on my ear to let you know so that you can remember to use your big person voice. Then I'll be able to understand what you're saying."
If the whine is repeated: "I still can't quite get what you're saying."
Initially, you might have to model the response you want. This means that you will have to "understand" what's been said so that you can repeat it back in the way you'd like to hear it.
Don't acknowledge their eventual acceptable statement with much more than a "thank you" - they've done nothing special, only what's expected.
Do acknowledge when they've asked nicely first time without whining or have gone all day without doing it - perhaps with something like, "My ears love that voice".
It can take up to a week or so, but generally they get sick of having to repeat everything they say, especially when it appears that you're not getting annoyed by it. It will work faster if all adults are on the same page with the same sort of light and calm responses.
With the more persistent whiner, hang in there, they will give up eventually. If you do feel ready to explode, you might suggest that they go to their bedroom for a good whine and come back when they're ready to talk to you properly.