Heartworm medicine refers to a type of medication used to prevent and treat heartworm infections in dogs, cats, and other pets. Heartworms are parasites that live in the blood vessels of the lungs and can cause severe health problems for animals if left untreated. The medicine works by killing or preventing the development of heartworm larvae before they mature into adult worms.