He is expected to be ready for spring training next year, the team said.
"To have the surgery, it clears away some of the uncertainty. I think this way it's a way to put it behind him and start fresh," manager Tony La Russa said.
"It takes the decision out of him and he can take his time and make sure he's 100%."
Madrigal was helped off the field after he tried to beat out a grounder in the seventh inning of a 6-2 loss to the Toronto Blue Jays on June 9. The No. 4 overall pick in the 2018 amateur draft had been rounding into form, batting .365 (27-for-74) with two homers and 10 RBIs in his past 20 games.
Madrigal is one of three key position players sidelined for the first-place White Sox. Left fielder Eloy Jimenez ruptured his left pectoral tendon during spring training, and center fielder Luis Robert tore his right hip flexor in May.
Madrigal, 24, finishes the season with a .305 batting average, 10 doubles, four triples, two home runs and 21 RBIs.
ESPN's Jesse Rogers and The Associated Press contributed to this report.