Our beagle does that when he gets excited or bored at auctions. We usually gently but firmly hold his mouth shut and say NO. You can try giving him treats for being quiet.