Substitute Castellanos scored a late second-half brace, including the dramatic 93rd-minute winner on Friday (AEST).
After equalising with seven minutes of regulation remaining, Castellanos smashed home his own rebound in the third minute of stoppage time.
Scores were level at half-time in New York, where Alexandru Mitrita's 16th-minute opener was cancelled out by Dynamo midfielder Juan Cabezas, while Houston's Romell Quioto was sent off for elbowing Ronald Matarrita.
The match was delayed for almost 80 minutes due to severe storms during the interval at Yankee Stadium.
When the clash resumed, Mauro Manotas put the visitors ahead in the 77th minute before Argentine midfielder Castellanos took centre stage in the Big Apple.
New York – which has played three games less than leaders Philadelphia Union – moved up to third in the Eastern Conference with its third win in four matches, while Houston is eighth in the Western Conference after three consecutive losses.