It depends. First check the laws in your state and area - and also ensure you're legally armed in the specific area you are. Whenever possible avoid trouble. Try to have the owner secure the animal. Call the cops if plagued by unrestrained dangerous animals.
Remember, people are funny when it comes to their dogs, even stupid vicious dogs. So whereas you and I should never have to suffer another unprovoked dog bite, I would exhaust all efforts to avoid trouble that can easily escalate into a confrontation with "two-legged dogs."
Legally an animal attack of a particularly vicious nature may certainly be grounds to defend yourself.
Of course the key is to certain of your target and, naturally, the backstop.
Remember a bullet once shot will continue on its path even if you change your mind. Dogs move quickly and I imagine it to be a hard target to hit. Your ability to exercise discretion over that round ends once the trigger is pulled.
It could potentially over penetrate, ricochet, or splinter into more than one piece if it strikes a solid object, and thus endanger innocent parties. Tracking a vicious, moving dog with your sights could mean you unintentionally swing your pistol around and cover an innocent person with your muzzle.
So where you may be legally (and certainly morally) allowed to defend yourself or a family member from a vicious dog attack. Remember Cooper Rule 4: Be certain of your target and what is beyond.
I find where legal, bear or pepper spray works very well also.