The Nats got three hits from Will Rhymes and two apiece from Jamey Carroll and Scott Hairston. They also benefited from a pair of errors by Astros shortstop Jonathan Villar, which led to four unearned runs against starting pitcher Jerome Williams.
The Astros struck against Nats starter Tanner Roark in the first, on Castro's RBI double to the warning track in right-center. Castro added a two-run homer off Roark in the third, ripping a pitch just inside the right-field foul pole.
Errors by Villar put the leadoff runner on base in both the second and fourth, and both times the Nats plated two runs. Williams exited after giving up a two-run single to Rhymes with two outs in the fourth, having allowed the four unearned runs on six hits, with no walks and three strikeouts.
Washington broke a 4-4 tie with a five-run fifth, highlighted by Fontenot's two-run single and McLouth's two-run homer.
Roark, part of the competition for the No. 5 spot in the Nats' rotation, gave up two runs on three hits in 3 1/3 innings, with two walks and three strikeouts.
The Astros got two runs back in the sixth and one more in the seventh, when manager Bo Porter challenged an out call at first base and had it overturned via instant replay, leading to Gonzalez's RBI single.
Up next: The Astros go back on the road on Thursday to face the Blue Jays at 12:05 p.m. CT in Dunedin, Fla. Left-hander Dallas Keuchel will make his third start of the spring. He goes into the start having tossed five scoreless innings, with only one hit and one walk allowed, to go along with two strikeouts. Collin McHugh and Josh Zeid are among the other pitchers scheduled to appear. Most of the position players will make the trip, except for Castro, Jose Altuve, Villar, Dexter Fowler and Marc Krauss.
Andrew Simon is a reporter for MLB.com. Follow him on Twitter @HitTheCutoff. This story was not subject to the approval of Major League Baseball or its clubs.