Bypass surgery can be performed as soon as a few days after a heart attack, depending on the patient's condition and the extent of the damage to the heart.