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 Nationals return to Space Coast Stadium to play the Mets on Thursday at 1:05 p.m. ET. This will mark the third time the two teams have faced each other this spring; the Nationals won the first two games. Left-hander Ross Detwiler, who has allowed four earned runs in 3 1/3 innings, will make the start.
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.