In the classic words of Norm from Cheers, "It's a dog eat dog world, and I'm wearing milkbone underwear."
I have had dogs charge me on runs and on the bike. In fact, one time the group I was riding with changed our route due to a dog. I only worry about it on the bike in that the dog could get tied up in the wheels and hurt us both.
I find most of their attempts are bluffs and they don't get within stricking (biting) distance. But, if they do, I throw a swift, stiff kick at them, and so far that has worked. I don't support kicking animals, but I do not want to get bit either. I have only had to do this twice.
When running - slowing down and facing them seems to keep them away, they are more likely to attack if you seem to be fleeing.
Best of luck,
JC1.5