The League of American Bicyclists recommends the following strategies for dealing with dogs:
Make sure that you do not hit the dog; you will fall and you might kill the dog
Stay in control of the bike; if you panic then you might lose control and fall
Try to not hurt yourself or the dog; you are just riding and he is just being a dog
Continue pedaling and ride past the dog; he is protecting his territory and should stop
Remember that some dogs bark and chase for fun with no intention of attacking
The faster you and your feet are moving, the less likely you are of being bitten
Yelling at the dog will usually startle the dog enough to get him to disengage
Spray water from your water bottle into his face; he'll get a drink and back off
Physical violence and pepper spray should only be used in extreme cases
How to Deal With Dogs - A more extended version:
A dog attack is one of the top fears on any road rider's lists. You may not be able to stop Cujo from chasing you, but you can outsmart him if you know how dogs think.
Dog Psychology 101
Most dogs that chase cyclists are merely following instinct and are defending their territory. As you pedal past the section of road they consider their turf, you no longer pose a threat and they lose interest.
Dogs like to attack from the rear. Even one who sits up ahead of you may wait till you pass before giving chase. You can use this to your advantage because you get a head start.
You often can out sprint Cujo if he is only guarding his tuff rather than actually attacking. Sometimes you can tell the intent. An easy gait with lots of barking and ears and tail up, there may be no problem. A full-out sprint with ears back, tail down and teeth out, you may have a problem. If the road is flat or downhill, stand up and sprint to get past their turf.
Shout It Out
Most dogs know what happens when a human is angry. A stern shout of "No!" or "Stay!" will surprise them and they may hesitate for the second you need to take the advantage. If that doesn't work, raise your hand threateningly as if it contains a rock. They may know this means trouble.
Guard Your Front
When a dog sees you coming, he will probably head straight for your bike, then turn up beside you. The danger for you is that he may skid on the pavement and he'll plow into your front wheel. If he hits it, you'll crash. Sprint so that you move forward faster than he expects. If traffic permits, give him a margin for error by drifting into the road.
If you see fast Fido up ahead and know he sees you, sprinting might not work, especially when the road goes up. Grab your water bottle – having it in your hand may slow him down. If not, give him a faceful and a loud yell. This distraction will slow him down, though he may come back for more. Just don't distract yourself and ride off the road.
Some riders swear by Halt pepper spray. This stuff works great – assuming you hit your target. That's a big question mark when you are trying to hit a moving target and you're trying to stay on the road.
These two tips are touchy because if they don't work it may be too late to effectively complete the next tip.
If all else fails and it look like the dog has the upper hand, get off the bike quickly and hold your bike between you and your enemy. If necessary, use your bike like a weapon and start calling for help. Someone may eventually come out of a house.
Call the Cops
If you are attacked and bitten, report it to authorities as soon as you get home. Be sure to include the location, a description of the dog, an account of what happened, and the owner's name and address if you know them. Get medical attention without further delay.
If the same dog accosts you every time you ride the road, report this to the authorities, too. You have a right to use public roadways free from fear for your life. Keep following up with calls to make sure steps are taken to put the dog on a rope.