This is where leadership comes into play. A dog behaviourist will look at the dog's routine, amount of exercise, boundaries, discipline etc. More importantly, they will look to see how you, as their leader, handle these situations. They will then teach you what you can do in your situation to correct and prevent the behaviour.
I'd like to share this article by Cesar Millan that touches on this and more:
Leading the pack
"One of the most important things dog lovers need to do is make sure they and their dogs are in tune with each other, with the humans being the pack leaders and the dogs following that lead. Notice I don’t say a dog should be well-trained. It’s very easy to train any dog to “sit” or “shake,” but this does not mean the dog is taking on the proper role in the pack. If a dog is not balanced, then it will go right back to misbehaving once it’s done whatever trick you’ve taught it. If you only focus on training without discipline, then you may wind up with your dog training you, using your reaction to its “cute” behaviour to get what it wants.
Setting the boundaries
I talk a lot about rules, boundaries, and limitations, which we need to create for our dogs to give them a sense of what they’re supposed to do. A pack leader’s job is to provide protection and direction. If you don’t give your dog direction, he or she can become anxious, frustrated, or fearful — and these are three of the biggest causes of common misbehaviours. You can help your dog achieve balance through my fulfillment formula of exercise, discipline, and then affection, in that order. All dogs need all of these things. It’s only the degree to which they need each one that varies with the dog.
Different dogs, different needs.
Dogs come in many different sizes and energy levels, so there is no “one-size-fits-all” rule on how much exercise a dog needs. Your dog needs as much as your dog needs. If you have a high energy Dalmatian, you may find it necessary for both of you to run several miles three times a day, but if you have an older, low energy mutt, then once around the block twice a day may do the trick.
The same goes for the affection part, in terms of feeding. Canine obesity is a serious health issue, so you don’t want to feed that inactive, overweight dog the same amount or type of food as you would a hyperactive greyhound. Consult your veterinarian to determine your dog’s ideal weight, then find the right exercise and nutrition program that will help him maintain that weight. How do you know when you’ve hit the right combination? Your dog will tell you with its balanced, calm-submissive energy— its way of saying “thanks!”for being a strong pack leader." - Cesar Millan