Jarred Cosart (2-3) allowed two runs and eight hits over six innings for the Astros, who had lost seven of eight before ending Baltimore's five-game winning streak.
Castro hit a three-run homer off Chris Tillman (3-2) in the first inning and Krauss connected against T.J. McFarland with a runner on in the seventh. Houston is 11-11 when it hits a home run and 1-15 when it doesn't.
Although the Astros' bullpen came in with a 6.21 ERA, Tony Sipp struck out five in two perfect innings and Chad Qualls worked the ninth for his second save.
Jose Altuve had three hits for the Astros, who improved to 6-12 against the Orioles - including 2-10 at Camden Yards.
This material may not be published, broadcast, rewritten, or redistributed.