Berkman also had a two-run single during a three-run fourth.
Darin Erstad's first homer this season, a three-run blast, capped a four-run eighth, created a 7-7 tie, and erased a 6-0 deficit after three innings. Also in the eighth, Carlos Lee launched a solo homer.
Lee, Mark Loretta and Kaz Matsui each had three hits for the Astros, who won three times in the four-game series.
The winner was Tim Byrdak (2-0) while closer Jose Valverde earned his 11th save.
San Francisco's John Bowker hit a sacrifice fly and a two-run double. Aaron Rowand had two hits, two RBI and scored once.
Randy Winn had two runs, three hits and one RBI and Omar Vizquel had three runs and three hits for the Giants, who have dropped eight of 11.
The losing pitcher was Vinnie Chulk (0-2).