The name is Dracunculus insignis. It is also known as the North American Guinea worm.
Your dog became infected by eating a reservoir host, like a frog or fish, or drinking water containing the intermediate host, a copepod. Copepods are tiny crustaceans (1-2mm in length) that live in the water. The larvae in these creatures penetrate through the dog's intestinal wall, then migrate through the dogs body, and the female worm eventually migrates up to the surface of the skin on the legs.
It is recommended to treat the dog with Fenbendazole or ivermectin, but that it is only helpful if the dog was infected recently (within 90 days). THe worms, other than the ones that show up on the legs, apparently do not cause much illness in the dog. THese are not transmitted to humans, so you do not have to worry. Your dog may continue to develop the nodules with the worms despite treatment with the dewormers mentioned above. Removal of the worms as they appear is recommened. Prevention will be by not allowing your dog to drink pond/lake water, not allowing him to eat frogs/fish, etc, as this will be a source of renewed infection.
Here is some info from the Michigan DNR:
http://www.michigan.gov/dnr/0,1607,7-153-10370_12150_12220-27119--,00.html
Another website with info:
http://cal.vet.upenn.edu/dxendopar/parasitepages/filariidsandspirurids/d_insignis.html