In order to answer this question, we have to look at the general law of self-defense, because the law usually considers a dog to be a weapon. So, you would have the right to use a dog for self-defense -- whether as a legal defense in response to a dog bite claim, for example. or in response to a crime or intentional tort -- in the same way that you could legally exercise any other method of self-defense. Following this logic, we have to determine when you are entitled to use force in your self-defense.
One important rule of self-defense is that you can’t use deadly force to defend property. So, if you had, for example, a trained guard dog that is capable of seriously injuring a person, you could not use the dog to defend against the possibility of property damage to your car. You could only have the dog attack if someone was attacking you. If you had a dog attack someone who was only attempting to steal your property, there is a good chance that you would be charged with criminal assault and you could also be held liable for civil assault and battery. You'd almost certainly face liability for dog bite injuries.
Another factor to consider in determining when you have the right to use force (or deadly force) in self-defense is your location. The laws on self-defense in many states differ depending on whether you are in your home or in a public place, or some other building.
For self-defense in one’s home, many states have adopted a rule called the "Castle Doctrine." This rule comes from the old rule that your house is your castle. The Castle Doctrine generally states that you have the right to use force, including possibly deadly force, to defend yourself against an intruder in your house.
So, if you are in your house when someone breaks in, and your dog attacks the intruder, you would almost certainly not face any criminal or civil charges for any injuries that your dog might inflict upon the intruder. And if you had a reasonable belief that the intruder was going to attack or possibly kill you, it would be very unlikely that you would face any civil or criminal penalties if your dog (or dogs) killed the intruder. Basically, the Castle Doctrine says that a burglar breaks into someone else’s home at his/her own peril.
But the Castle Doctrine does not apply in public. Further, in most states, you have the duty to try to retreat from a threat in public before using force in self-defense. Some states have an exception to the duty to retreat, called a "Stand Your Ground" law. These laws exempt you (and your dog) from having to retreat from a threat in public before you can use force in self-defense.
Another important factor in thinking about self-defense is the level of the threat you face. You have the right to use more force in self-defense than the level of force you think you are facing, but not too much more force. If, for example, an obviously unarmed (and not very large) ten year old boy stops you on the street and demands your wallet, you don’t have the right to shoot him. You might not even have the right to hit him, depending on the exact circumstances. And you almost certainly wouldn’t have the legal right to order your dog to attack him. (In personal injury law, the appropriate response in these situations comes down to an evaluation of what a reasonable person would do.)
But, as a general rule, the greater the threat you reasonably think that you are facing, the more force you have the legal right to use in self-defense. So, while you couldn’t have your dog attack a ten year old boy who has no weapon, you probably would have the right to have your dog attack a much older and larger boy (or man or woman) who either has a weapon or who poses a very serious and significant threat to your physical safety.
If you have a dog that you are thinking about using for self-defense, it's critical that you get familiar with your state’s laws when it comes to legal defenses to both criminal and civil liability. In some situations, it may make sense to talk to an attorney and get a sense of the legal landscape before you end up facing potential liability.