Gonzalez (4-4) walked four and struck out five in six innings. It was the left-hander's second start following a monthlong stint on the disabled list for left shoulder inflammation.
He outdueled Matt Garza (4-5), who struck out seven in seven innings but allowed LaRoche's homer to straightaway center in the third.
Tyler Clippard struck out the side in the ninth for his first save.
Brewers cleanup hitter Carlos Gomez went 0 for 4, snapping a 35-game streak of reaching base and a career-best 18-game hitting streak.
He flied out to left with two outs and the bases loaded to end the third, the Brewers' best chance to break through at the plate.
Otherwise the NL East leaders were in good shape with Gonzalez, who skirted a couple of jams and left after throwing a season-high 114 pitches. Washington snapped Milwaukee's four-game winning streak.
Gonzalez got leadoff hitter Rickie Weeks to pop up to shallow center on an 89 mph fastball on an 0-1 count. His night ended by getting Khris Davis to ground into a 6-4-3 double play after walking Aramis Ramirez with one out in the sixth.
Gonzalez flashed a wide smile and got a hug from a coach in the dugout following a satisfying performance. The bullpen took over from there, with Clippard closing the game after regular stopper Rafael Soriano had worked the previous three nights.
The Brewers were shut out for the first time since losing 8-0 on May 31 to the Chicago Cubs and starter Jason Hammel.
Garza, the Brewers' big offseason acquisition, got a big confidence boost after escaping a bases-loaded jam with no outs in the second by striking out Danny Espinosa and Jose Lobaton before getting Gonzalez to bounce into a fielder's choice.
But Garza couldn't get out of the third unscathed after walking Anthony Rendon and allowing a single to No. 3 hitter Jayson Werth to bring up LaRoche.
That's trouble in Miller Park, where LaRoche has homered in three straight games dating to last season. On Monday, he hit a full-count pitch from Garza off the black wall beyond the fence in center field 400 feet from the plate.
Garza pounced off the mound as LaRoche rounded the bases, angrily swinging his glove down into his right hand.
NOTES: Nationals manager Matt Williams was ejected after an argument with home plate umpire Mark Wegner after the top of the second. Espinosa was called out on strikes in that inning on a fastball from Garza along the outside corner. ... Nationals OF Bryce Harper (left thumb) began a rehab stint Monday at Class-A Potomac, where he started in left field and played three innings, as planned. Harper finished 1 for 1 with a single, walk and run scored. C Wilson Ramos, also rehabbing at Potomac from a strained right hamstring, went 3 for 4 with a three-run homer. ... Brewers RF Ryan Braun started and went 1 for 4 a day after a minor left ankle sprain during Sunday's 6-5 win at Colorado. Manager Ron Roenicke said closer Francisco Rodriguez was fine after he hurt his left ankle in the same game. ... Washington's Jordan Zimmerman (5-4) opposes Milwaukee's Yovani Gallardo (5-4) on Tuesday night.
Follow Genaro Armas at http://twitter.com/GArmasAP
(Copyright 2014 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)