Pienaar, who came from the bench with 20 minutes to go, arrived back in Belfast earlier this week following his international duties with South Africa in the Rugby Championship over the last month.
Despite the clock showing 80 minutes, Castres, who had nothing to play for at this point, kept playing and when they lost the ball on Ulster’s 22, the ball went wide and Pienaar was at the end of a superd 80-metre move to score his side’s fourth try.
The home side, who saw Stephen Ferris withdraw just before the game with back spasms, started in emphatic fashion running the French off their feet with brilliant offloads but struggled to control the Castres rolling mauls to see them come back into the game.
It looked like they had the game under control early in the second half to chase the bonus-point but a number of missed opportunities prevented them from crossing the line again until Pienaar’s run.
Castres, who had left some key player on the bench, looked set for a hiding early in the second half but stayed into the game thanks to their huge pack led by former Ulsterman Pedrie Wannenburg and even forced Ulster to make uncharacteristic mistakes all through the second half.
Once the first 20-minute storm gone, they got up to speed and managed to put Ulster on the back foot but they were too far behind by this point.
Romain Teulet and Paddy Jackson exchanged early penalties before Jared Payne made a superb break through the middle to find Andrew Trimble on his shoulder and send the Ireland winger in the left corner.
Jackson added the extras from the touchline and a further penalty to put Ulster 13-3 in front after fifteen minutes.
The Irish increased their lead soon after when scrum-half Paul Marshall inherited of a turnover ball 40 metres out, chipped it through and scored under the posts.
But Castres didn’t give up and managed to get back into the game when winger Marc Andreu collected a cross-filed kick from Pierre Bernard following some good work on Ulster’s line.
Ulster’s hit straight back to see Jackson kick his third penalty of the half and Ulster were leading 23-10 at the break.
The home side scored their third try early when man-of-the-match Marshall barged over from five metres to take the lead to 28-10 and have the try bonus-point in sight.
Jackson kicked his fourth penalty to secure a little bit more the game before former Worcester winger Marcel Garvey reduced the deficit to 14 points for Castres with a try from close range.
But Ulster weren’t going to be denied and Jackson sealed the win with 20 minutes to go with his fifth penalty.
Castres were immense in defence to keep the Irish away and the bonus-point looked to have slip away but Pienaar eventually sent the crowd off their feet with the last action of the game.
For Ulster:
Tries: Trimble, P. Marshall 2, Pienaar
Conversions: Jackson 3
Penalties: Jackson 5
Sin Bin: Court
For Castres:
Tries: Andreu, Garvey
Conversions: Teulet 2
Penalty: Teulet
Sin Bin: Forestier
Ulster: Payne; Bowe, Cave, Wallace, Trimble; Jackson, P. Marshall; Court, Best, Afoa; Muller (capt.), Tuohy; Henderson, Henry, McComish.
Replacements: Herring, Black, Macklin, Stevenson, McComb, Pienaar, L. Marshall, Gilroy.
Castres: Teulet; Garvey, Bai, Kirkpatrick, Andreu; Bernard, Lacrampe; Forestier, Bonello, Coetzee; Rolland (capt.), Capo-Ortega; Faasalele, Caballero, Wannenburg.
Replacements: Rallier, Marmoiton, Lazar, Tekori, Claassen, Kockott, Bonnefond, Sanchou.
Star man: Paul Marshall – Ulster
Referee: Andrew Small (England)
NICK VERDIER