I respectfully disagree with almost all of the above responses.
A dog has two primary weapons. Mass and teeth. Secondary weapons are claws, which some can use with some effectiveness in defensive situations (when it is attacked or the prey fights back). It knocks smaller animals (and some larger animals) over and it savages them with its teeth. Wolves are dogs, and the way they hunt is instructive. They go for trailing limbs, attempt to tear open arteries, weaken the prey, and bowl it over, where they kill it.
A small child has no chance to fight off a large dog. The only possible defense is to quickly assume the fetal position, and to protect their neck and the inside of their thighs, where the major arteries are, and to start screaming for help.
An adult can do the same thing, or if they choose to fight, they must immobilize the primary weapon, the teeth. That means getting control of the dog's head and clamping the mouth shut. A dog has tremendous biting power, but not so much muscle to OPEN the jaw, so if it is held shut, it will not be able to administer a bite. It also burns tremendous energy reserves when fighting and must breathe through its mouth; it cannot breathe through its nostrils and still exert huge amounts of energy. Most adults are larger than most dogs, so it is important to get on top of the dog physically, quickly. The adult must use their body mass to force the dog to the ground, immobilizing it to the extent possible. Dogs cannot grasp and cannot wrestle. Though they are limber, there are many directions that creatures that never swung from trees cannot bend. Adult human punches to the dog's exposed bones, such as ribs, when the dog is pinned, will break them. Dogs will instinctively retreat when they are injured and they know it; their self-defense instinct is more powerful than their fight instinct. Although I am no fan of injuring dogs, the human must inflict actual serious damage to the attacking dog to ensure it will immediately disengage the attack and run away if it can still move.
Of course, if one can carry things around with them, pepper spray *may* work (and it may not, dogs are not the same as humans), plus it is illegal in many jurisdictions and it requires precision application AND you're going to get a does of it also. A stick is good, a can, something of that nature. If you're adept and it's possible, tree-climbing will work, since dogs cannot climb trees and have short attention spans. A gun or a knife can also be quite useful, with the usual caveats about legality of carry where you live and so on.
Dogs can be quite dangerous. I believe they are more dangerous to children than adults, and children have the least chance of fighting them off. I believe a child should focus on protecting their vital areas, rather than self-defense against an attacking dog. That is not a guarantee, of course. A pack of dogs is another matter, and a child may well simply have no chance of survival against one.