The surprising Nationals have won three in a row and have captured 10 of their 13 games this season.
Houston, which has dropped four straight, owned a 2-1 lead going into the ninth, but Fernando Rodriguez (0-2) loaded the bases on two walks and a single before being relieved by Wesley Wright.
Wright then walked Jayson Werth on a 3-2 count to bring in the tying run and, one out later, surrendered the game-winning sacrifice fly to Ramos.
That made a winner out of Ryan Mattheus (2-0), who in relief of Ryan Zimmerman gave up two hits and a run in the eighth that briefly gave Houston the lead. Henry Rodriguez worked a perfect ninth for his third save.
NBC reportedly holds celebs hostage to Jimmy Fallon's show
Aaron Carter is still in love with Hilary Duff