Heartworms are transmitted to dogs through the bite of infected mosquitoes. The larvae then mature and grow inside the dog’s body, residing in the heart, lungs, and blood vessels.