Dog heartworm is caused by a parasitic worm called Dirofilaria immitis, which is transmitted through the bite of an infected mosquito. Once a dog is bitten, the worms travel through the bloodstream, eventually settling in the heart, lungs, and blood vessels, where they mature and reproduce.