Dogs get worms in a variety of ways, but one of the most common is exposure to eggs that were shed in other dogs' feces. Many puppies get worms from their mother's milk if she is infected.
The method of transmission varies depending on the type of worm. Roundworms and hookworms are commonly transmitted from mother to puppy. This occurs when the mother had a dormant infection that her immune system kept in check until the stresses of pregnancy and nursing. Once the worms become active, they travel to the puppies.
Adult dogs usually catch roundworms, hookworms and whipworms from eating eggs that other dogs have shed. These eggs are microscopic and can live in the soil even after the infected droppings have been removed. Hookworms are also able to burrow through a dog's skin if it walks through an infested area.
Tapeworms are usually spread by fleas rather than directly from dog to dog. A flea picks up a tapeworm egg, then transmits it to the dog when it bites. Other tapeworms live in rabbits, but dogs can get them by eating an infected rabbit.
Heartworms are one of the most serious types of parasite a dog can get because they live in the heart and blood vessels. Heartworm infection can lead to death if not treated. They are transmitted by mosquito bites.