Maximiliano Moralez assisted on both goals as NYCFC (10-6-4, 34 points) improved to 8-2-1 at home. NYCFC is 5-1-2 in their past eight overall matches.
The 22-year-old Castellanos has 10 goals, one shy of his career-best total in 2019.
The setback halted New England's four-game winning streak as well as its nine-match unbeaten stretch (8-0-1). The league-best Revolution (15-4-4, 49 points) were on the losing end for the first time since falling 3-2 to Toronto FC on July 7.
New England dropped to 6-3-3 on the road.
NYCFC goalkeeper Sean Johnson posted his sixth shutout of the season but was called on to make just one save.
New England All-Star goalkeeper Matt Turner made three saves.
NYCFC had a 19-12 edge in shots and put five on target. The Revolution placed just one shot on target -- Adam Buksa's left-footed long-range attempt in the 76th minute that was stopped by Johnson.
New England's Gustavo Bou was wide left on a right-footed shot three minutes later.
Moralez and Castellanos teamed up in the 31st minute for the first goal. Moralez lofted a pass over the pack to a speeding Castellanos, who was in free to send a header past Turner.
The referee initially wiped out the goal, citing Castellanos was offside, but a video review displayed that the goal was valid.
The duo were at it again in the 55th minute. This time, Moralez delivered a stellar cross from the right wing. Castellanos was streaking toward the goal and volleyed the ball past Turner to make it 2-0.
New England's best first-half scoring chance came in the 24th minute when Buksa snapped a close-range header. But NYCFC's Jesus Medina immediately blocked the shot with his own head and the ball went just right of the net.