Manager Bruce Bochy said ''it was inevitable'' that Cain would have surgery. Bochy said after Monday's 4-3 win over the New York Mets that Cain would have the operation and look forward to getting ready for spring training.
The 29-year-old Cain hasn't pitched since July 9. The three-time All-Star played catch at Citi Field on Friday to test out how he was feeling.
Cain was 2-7 with a 4.18 ERA in 15 starts.
The Giants are in the race for the NL West title. They recently acquired veteran pitcher Jake Peavy in a trade with Boston.