The unusual offensive outburst for the team with the worst record in the majors gave the Astros just their third win in 14 games.
Houston scored four times in the second with Robbie Grossman hitting a two-run home run. The Astros added five in the fourth, the key to the inning being Castro's 13th home run of the season.
All of that gave Brett Oberholtzer the win in the first start of his major league career. He had made three relief appearances since being called up and was given the start to fill in for Bud Norris, who was dealt by the Astros prior to the trade deadline.
Oberholtzer (1-0) allowed three of Baltimore's seven hits over seven innings.
The loss went to Miguel Gonzalez (8-5), who gave up four runs on nine hits in 3 2/3 innings.