It is caused by bacteria that enter the bloodstream. Once in the blood, these bacteria can infect the inside of the heart. During surgical procedures. After an injury with an open wound. With shared needles during drug use.
Bacteria are more likely to cause an infection in the heart if the heart is already damaged.
Dentists and doctors often prescribe antibiotics to persons with heart damage before they do any invasive procedures. For example, persons with damaged heart valves will often take a course of antibiotics before dental procedures. An infection of the heart lining is very serious. People with bacterial endocarditis need treatment with antibiotics given by vein. After these medicines are stopped, they will probably have to take antibiotics by mouth for a time.