Surgery, such as a colectomy, is indicated when there is no response to medical therapy, or in cases of perforation, hemorrhage, or peritonitis. The decision to proceed with surgery is often complex and requires careful assessment and consultation with a surgical team.