The announcement was made by manager Bruce Bochy before the defending World Series champions opened a three-game series with the last-place Dodgers on Monday. The procedure to repair a tendon will be performed by Dodgers team physician Neal ElAttrache at the Kerlan-Jobe Clinic in Los Angeles, and Pagan is expected be out at least another 12 weeks.
Pagan, who turns 32 on July 2, signed a four-year, $40 million contract in December after helping the Giants win their second World Series title in three years. He is batting .262 with three home runs and 24 RBIs.
Also Monday, the Giants recalled reliever George Kontos from Triple-A Fresno and optioned right-hander Jean Machi to their Pacific Coast League club. Right-hander Chad Gaudin was placed on the 15-day DL because of a bruised elbow and lefty Mike Kickham was recalled from Fresno.
Pagan hasn't played since his inside-the-park homer lifted San Francisco to a 6-5 victory over the Colorado Rockies on May 25.
He sustained a small tear when he aggravated the leg injury during a rehab game with Class A San Jose on Thursday night. He then met with team orthopedist Dr. Ken Akizuki and opted to get a second opinion.
"After getting the second opinion, the consensus was that surgery's the best option right now," Bochy said.
It was the latest dose of bad news for the Giants, who entered Monday trailing NL West-leading Arizona by three games. It came on the same day they reinstated slugging third baseman Pablo Sandoval from the disabled list after he missed 14 games because of an injured left foot.
Kontos was optioned to the minors on June 11, the day he received a three-game suspension for throwing a pitch at Pittsburgh's Andrew McCutchen. He is appealing the penalty and is eligible to play until his case is heard by Major League Baseball.
Gaudin was struck by a line drive on Thursday, and Kickham will make his second major league start on Tuesday night in his place. He made his major league debut May 28 in Oakland, giving up four runs, four hits and four walks in 2 1-3 innings.