There are various ways of dealing with dogs while running. Some of the methods depend on both your personality and the personality of the dog. Knowing the laws in your state or municipality will also help determine the proper way to deal with stray dogs.
Depending on what you read, you will find all kinds of recommendations on what should and should not be done when a dog aggressively approaches a runner. What one "dog expert" says may be completely opposite from what another recommends. My recommendation is that you look at these different approaches and see which one will work for you. Your personality will also dictate, to some degree, what the best course of action is for you.
Often a dog sees the runner as someone/something that is invading his territory. This either excites him into wanting to play, or prepares him for attack. When a dog is running after you, you probably are not thinking that the dog wants to play, but you should at least attempt to find out before proceeding. When you are running, you are doing something that the vast majority of the people the dog encounters does not do. It may be strange for a dog to see someone moving in such a manner. It can be disturbing to the dog making him think that something is unusual and wrong. Again, this could make the dog interested in playing or attacking. A dog could sense that this strange action you are doing is exciting and fun, or threatening and potentially harmful to him.
Depending on the laws in your area, you may be able to prevent a bad encounter before it starts by informing the animal control authority in your area when you see a stray animal. Reporting stray dogs in a neighborhood (if there are not supposed to be any dogs loose) is a help to the dog, the owner and to you as a runner. If the dog is loose and the owners either do not know where the dog is, or unaware that he has gotten out, then you are helping the owner. Sometimes dogs don't know how to deal with traffic, other animals or people. For the safety of the dog it is important to report stray animals when you see them.
Here are some specific recommendations on what to do when a dog starts towards you while running.
Stop and speak to the dog in a soothing tone. Often this will give you a quick understanding of what the dog may be thinking. His body language may tell you that he is just curious. It may also tell you that you are perceived as a threat. Hopefully talking to the dog will calm him down enough so that you can walk away slowly and continue on your run.
If the dog continues to be aggressive you may need to raise your voice and physical attitude from something calming to something more authoritative. Start by yelling sharp short words to the dog. "Stop!", "No!", "Stay!" or any other words that might be familiar to the dog.
Depending on the dog's, and your, personality, making eye contact with the dog could be the best, or worst thing you can do. A dog sees this as a very aggressive move on your part. Direct eye contact may cause him to consider you as a serious threat. The question then becomes, are you aggressive enough to make the dog back down?
If you are willing to stand your ground and fight the dog, then taking the direct eye-contact approach may give you the upper hand in the battle. Follow that up with advancement towards the dog. By moving towards the dog you are again taking an aggressive move. This may be enough to show the dog your intent to win a fight. You hope the dog backs down, or you may be in trouble.
If, however, you are not willing to fight the dog in an aggressive way, it is best not to make direct, threatening eye contact. Try to do everything you can to slowly move away from the dog. If you cannot get away, but the dog is not coming any closer, then just keeping the dog barking may be enough to get the dog's owner to come rescue you. And, if you are rescued by the owner, be gracious to them. Threatening them or their dog at that moment is not helpful. The best thing to do is to call the authorities and have them take care of the matter.
If the dog continues his aggression and seems like he is going to attack, bring your arms and legs together so that you don't have any limbs sticking out that are easy for the dog to grab. At this point you are preparing to potentially be attacked. The whole time you should be shouting and trying to get the dog to back away.
At what point do you change from a position of defense to a position of attack? Some people say that one should never attack a dog unless actually bitten. The thinking is that the dog is only defending his territory and it is not his fault that you are invading his space. (Of course, you should be certain that you are not on the private property of the dog owner, otherwise you have no legal help to protect you.) Others say that one should have as much of a right as the dog has to defend himself. This is obviously a decision that the individual needs to make.
If there is a need to defend yourself from an attack, you should only use as much force as necessary to safely get away and call animal control. This may be as simple as throwing a rock towards the dog, to as violent as showing a dog what shoe leather tastes like. Carrying a can of mace or similar product can be a help.
Regardless of the depth of interaction you have with a dog, if it is out of its property area, or not leashed when it should be, you should call animal control. The owners will not be happy to be served a warning, but they would be less happy if their dog ended up attacking a child, or was hit by a car because of their carelessness.
A dog can be a wonderful companion and friend. But a dog that is not properly cared for is a risk to himself and others who may otherwise be innocent bystanders.