The team said the surgery was performed Tuesday in Cincinnati to repair a partial tear of Pena's rotator cuff and a tear of his labrum.
"It was a devastating surgery," general manager Jim Bowden said in San Francisco, where the Nationals opened a three-game series. "The doctors didn't expect it to be so severe."
That's because Pena played through all of the shoulder problems for most of the year.
Pena, who batted .205 with two home runs and 10 RBIs, had been on the 15-day disabled list since July 18. The shoulder will be placed in a sling for three weeks before Pena begins rehabilitation. He's expected to be ready for next season's spring training.
Pena was acquired by the Nationals from Boston in August 2007.