An EKG is a test that detects and records the heart's electrical activity. It may be used to see if endocarditis is affecting the heart's rhythm.