Gallardo homered and struck out six in his first start since being arrested on a drunken driving charge, and the Milwaukee Brewers beat San Francisco 7-2 Thursday for a three-game sweep.
"It was tough," Gallardo said. "It's obviously something you don't want to ever run into or happen.
"There's different things we all go through, different situations. We all have stuff off the field.
Something like that is a big deal. It's serious. I apologize. I'm just going to do everything possible and everything I have to do so something like that doesn't happen again."
Gallardo (1-1) was arrested early Tuesday morning.
The right-hander allowed five hits, one walk and one earned run in six innings.
Milwaukee took all three games from the World Series champion Giants and won its season-high fourth in a row after a 1-8 skid.
"The guys in here, they know what kind of person I am," Gallardo said. "It's one of those things, obviously, we all know what happened was a mistake. It wasn't the brightest thing. But the guys are behind me."
Ryan Braun and Jonathan Lucroy also homered for Milwaukee, which swept San Francisco for the first time since July 18-20, 2008.
"I think Yo had something to prove and obviously wasn't happy with what happened a few days ago," Milwaukee manager Ron Roenicke said.
"Yo is really well-liked here. And they know how hard it is on him, and what he's going through. I think this is a tight bunch of guys and I think they really pull for each other."
San Francisco lost for the fourth time in six games and fell to 0-4 when Matt Cain pitches.
Cain (0-2) gave up seven earned runs and seven hits while striking out four without a walk in six innings.
Milwaukee had a 7-0 lead after three innings.
"It didn't really matter what pitch it was in those three innings," Cain said. "Everything was coming back to the middle. Right in the middle. I was just not executing the pitches at all."
Gallardo's two-run homer was his first of the season and 11th of his career, the most by a Milwaukee pitcher.
Braun hit his third homer of the year, a two-run shot in the first. He had been in a 1-for-18 slump, including 11 strikeouts.
In the second, Carlos Gomez was hit with a pitch, stole second and scored on a single by Yuniesky Betancourt. Gallardo's homer to left made it 5-0.
Lucroy added his two-run homer in the third for a 7-0 lead.
Gallardo had allowed 12 earned runs in his past three starts, but his only blemish came in the fourth. He gave up a leadoff double to Brandon Crawford, who scored on a sacrifice fly by Brandon Belt.
Gallardo was aggressive with his fastball and was throwing it for strikes to improve to 40-19 at Miller Park.
"I think he threw really well," Lucroy said. "That's the best I've seen him throw this year. I could tell in the bullpen there was something different about him today."
Once he left the game, relievers Michael Gonzalez and John Axford each pitched a scoreless inning before Alfredo Figaro gave up a solo homer to Crawford in the ninth. Crawford had three hits.
Cain settled down and retired 11 of his final 12 batters. But he has allowed five homers in his past two games after not allowing one in his first two outings. He has also given up 18 earned runs and 21 hits in his past three starts.
"I will say, Cain gave us a gutty effort," San Francisco manager Bruce Bochy said. "He regrouped and made a nice adjustment. He pitched great the last three innings. But, when you give up three two-run homers, that is hard to overcome."
NOTES: The last time Milwaukee swept San Francisco at Miller Park was also in 2008. This is the Giants' longest losing streak since dropping five straight from July 25 to 30 last season. ... This was the fourth time Gallardo and Cain squared off, and all have been at Miller Park. Gallardo improved to 3-1. ... Crawford and Hunter Pence are the only Giants to have started all 16 games. ... Crawford extended his career-high hitting streak to 11 games with a single in the second. ... The Brewers reassigned RHP Mike Fiers to Triple-A Nashville and will announce a corresponding move at a later time. Fiers was 0-1 with an 8.59 ERA in three appearances.