The two blasts gave the National League East-leading Nationals a 9-0 lead and handed them a series-evening victory in the second contest of a four-game set.
Desmond finished with three hits while Adam LaRoche went 3-for-4 with a solo homer, two RBI and three runs scored. Washington banged out 13 hits.
Gonzalez (20-8) became the first major league pitcher to reach the 20-victory plateau this season -- and the first for the Nationals franchise since Ross Grimsley went 20-11 in 1978 for the Montreal Expos.
The left-hander won for the fourth time in five starts, limiting the Brewers to three runs (two earned) on three hits over seven innings, walking one and striking out five.
Milwaukee's Wily Peralta (2-1) absorbed the loss, yielding three runs on five hits over 2 2/3 innings.
Taylor Green hit a two-run homer for the Brewers, who came into the contest trailing the St. Louis Cardinals by 1 1/2 games for National League wild-card spot.