Surface electromyography (sEMG) has been widely used in the study of clinical medicine, rehabilitation medicine, sports, etc., and its endpoints should be detected accurately before analyzing. However, endpoint detection is vulnerable to electrocardiogram (ECG) interference when the sEMG recorders are placed near the heart. In this paper, an endpoint-detection algorithm which is insensitive to ECG interference is proposed. In the algorithm, endpoints of sEMG are detected based on the short-time energy and short-time zero-crossing rates of sEMG. The thresholds of short-time energy and short-time zero-crossing rate are set according to the statistical difference of short-time zero-crossing rate between sEMG and ECG, and the statistical difference of short-time energy between sEMG and the background noise. Experiment results on the sEMG of rectus abdominis muscle demonstrate that the algorithm detects the endpoints of the sEMG with a high accuracy rate of 95.6%.