Lee (13-6) gave up two runs on five hits and allowed a lone walk in winning his third straight decision.
Galvis scored the go-ahead run in the seventh on a ground out by Cesar Hernandez and drove in runs with a homer in the fifth and a sacrifice fly in the eighth. Jimmy Robbins also homered for the Phillies in the sixth.
The San Diego runs were produced by homers from Tommy Medica in the fifth and Jedd Gyorko in the sixth. Medica's home run came in his major league debut and was his first hit.
The loss was charged to reliever Nick Vincent (4-3), who gave up the go-ahead run in the seventh. San Diego had a four-game winning streak snapped.
Jonathan Papelbon came on in the ninth to earn his 26th save.