Surgery is typically recommended when a congenital heart defect is causing significant symptoms such as difficulty breathing, poor weight gain, or repeated lung infections. In some cases, surgery may be required to prevent future complications, such as heart failure or pulmonary hypertension.