An ECG (or EKG) is short for electrocardiogram and is a tracing of the heart's electrical activity. It can be used to diagnosis abnormal rhythms and even heart attacks.
There are two main variables that determine when a pilot will need to have an ECG/EKG completed with their medical certificate - Age and Medical Certificate Category.
The below table comes directly from the FAA AME Guide.
For Air Traffic Controllers, an EKG is needed at slightly different time intervals. See below.
REFERENCE:
For AME's, here is the guidance directly from the AME GUIDE