Harper, who said he has felt no pain in his surgically-repaired left knee this spring, hit a two-run homer off Astros starter Brett Oberholtzer in the first inning.
Ramos followed three batters later with a three-run drive that may have gone out of Space Coast Stadium.
Washington closer Rafael Soriano saw his first action of the spring and gave up two runs on three hits in one inning.
Marc Krauss went 3 for 4 with a home run for the Astros. Carlos Corporan had two RBIs.