The Brewers won for the fifth time in seven games, overcoming an early homer by San Diego's Nick Hundley.
Gomez gave Milwaukee a 2-1 advantage with his blast and the Brewers picked up another run in the seventh when Hundley threw wildly in a bid to catch Gomez stealing second. The bad throw allowed Norichika Aoki to score from third.
Kyle Lohse (7-7) allowed a run on five hits over seven innings to get the victory, his fourth in five starts. Jim Henderson worked around a walk in the ninth to capture his 11th save.
The setback was suffered by Sean O'Sullivan (0-2), who gave up three runs on seven hits in 6 1/3.