Barking is a totally natural aspect of a dog's behavior and you must expect your puppy to grow into a dog that will bark. It is unrealistic, even unfair, to think you can train your dog to stop barking, but you, your family and neighbors will be happier if you can bring it under control.
"Stop barking": It's hardly surprising many people have barking problems with their dogs; dogs have no idea whether barking is something good or bad. That's because, sometimes when a dog barks, he is ignored; at other times he is shouted at to stop; then again he may be encouraged to bark if, for example, there's a suspicious, stranger nearby. So to help your dog know the rules, here's a helpful rule to start with; barking is acceptable until he is told to stop.
"Stop Barking" should be considered as a command for obedience rather than a telling off. You should let your dog bark two or three times, praise him for sounding the alarm, then say "Stop Barking" and hold out a treat in front of him. Your dog will stop straight away because he can't sniff the treat while barking; after a few seconds, give him the reward. Gradually increase the time when the barking stops to the giving of the reward and you will be able to stop your dog barking for as long as two minutes in just one training session, see Clicker training.
However, if you become worried or concerned about excessive barking that you have no control over, you should seek advice from your vet about next steps, such as specialist training or therapy.
Whining: This may sound heartless, but you should understand that going to comfort your puppy when he whines will actually make things worse. He'll think he's being praised for whining, and get into the habit. In fact, you can help him learn to stop by not going back to him when he whines. By ignoring your puppy, and only giving him attention and praise when he stops whining, he'll learn that whining and whimpering is not the way to solve things.