Twente have 37 points from 17 matches, one point ahead of PSV Eindhoven, who are in action on Saturday at NEC Nijmegen, with Vitesse Arnhem in third place on 34.
Twente, smarting from a 3-0 defeat at PSV last week, came from behind to win after Marko Vejinovic's opener with Nacer Chadli and Edwin Gyasi getting on the scoresheet before Thomas Bruns equalised for the visitors.
The hosts had dominated from the start with Chadli shooting wide and Dusan Tadic striking the post from a tight angle.
However, it was Heracles who went ahead against the run of play after 20 minutes through Vejinovic's free kick that went through the wall and into the net off the post.
Six minutes later Chadli levelled after a blunder by keeper Remko Pasveer had allowed Wout Brama to set up the chance.
Twente took the lead just past the hour when youngster Gyasi rounded two defenders to score but the visitors equalised soon after when the unmarked Bruns fired home a fierce shot.
It was left to striker Castaignos to settle the match when he tapped into an empty net after fine work from Chadli.
"We made some changes to our tactical plan with (Dusan) Tadic as playmaker because Heracles are used to playing with three defenders," said Twente captain Wout Brama.
"And that worked out fine although we had to come from behind after missing several chances."
Heracles coach Peter Bosz added: "We stayed in the match for a long time but finally we lacked quality and seeing the number of chances Twente created they deserved the win."