My dog does something like that too... And, if I put him outside that helps.
However, I believe that the whining in my case is related to feeding time. Dogs have an insulin response similar to our, and their biological clock for getting fed is pretty accurate. So, my dog whines for feeding about 30 min. before the time that I fed him the day before. I did a minor experiment, and if I fed him earlier, then he'd whine earlier... I didn't go all the way to see if he'd wake up in the middle of the night to get fed
Keep feeding him at the same time... but ignore him if you can, or let him out if you must ... and still ignore him. Don't feed him earlier
