Strasburg (14-5) struck out seven in notching his fourth win over five starts, allowing a pair of runs while overcoming four walks.
Espinoza's blast in the third inning broke a 2-2 tie and the Nationals used three RBI from Jayson Werth to help take the rubber match of a three-game series.
Steve Lombardozzi went 4-for-5 with a run scored for the National League East-leading Nationals.
Tim Lincecum (6-13) was touched for four runs on eight hits over four innings for the Giants, who were stunned before the game when leading hitter Melky Cabrera was suspended for 50 games for using performance enhancing drugs.
Brandon Crawford knocked in a pair for the Giants, who came into the contest tied with the Los Angeles Dodgers for the top spot in the NL West.
Swim Week Miami Beach 2014 [PHOTOS]