The homer, Sandoval's 25th of the season and his second hit of the game, broke a 3-3 tie leading off the top of the 10th.
Juan Uribe hit an RBI double, two runs scored on double play groundouts, Eugenio Velez had three hits and Andres Torres had two hits for the Giants (88-74), who finished third in the National League West.
The winner was Jeremy Affeldt (2-2).
Closer Brian Wilson earned his 38th save.
San Diego's David Eckstein hit a two-run sixth-inning homer and a run scored on Eckstein's foul pop in the seventh for the Padres (75-87), who finished fourth in the NL West.
The losing pitcher was Ryan Webb (2-1).
Copyright 2009 by United Press International.