With qualification already secured, Ulster must now wait for the final matches from Pools 1, 2, 5 and 6 to be played.
Mark Anscombe's men will benefit from a home draw in the last-eight should neither Toulouse, Saracens or Montpellier achieve a bonus point victory this weekend.
Personnel changes to the starting line-up - two tacticala dn two enforced - saw Craig Gilroy start in the unfamiliar position of full-back in place of the unavailable Jared Payne, a switch which in turn brought in Michael Allen on the wing for his first European start.
Meanwhile, Pienaar moved to out-half in lieu of Paddy Jackson, paving the way for Paul Marshall to start at scrum half.
Up front Neil McComb was preferred to Iain Henderson at lock, while Roger Wilson donned the number 8 shirt in the absence of the injured Nick Williams.
Ulster held a strong foothold in the scrum with Tom Court and John Afoa again excelling in the front row, but a lack of quality possession and a combination of poor decision-making and loose lineout play nullifed Ulster's threat.
The visitors started the match strongly with Pienaar electing to kick two early penalties to touch rather than going for the posts.
However, Castres absorbed the pressure well and indeed got on the scoresheet first courtesy off a right wing breakaway try grounded by Rémi Lamérat in the eighth minute. Rory Kockott's conversion attempt veered wide in the swirling wind.
Pienaar retrieved three points immediately with a firmly-struck penalty from 41 metres, only for Kockott to restore the five-point lead in the 18th minute with a close range effort after Paddy Wallace had been pulled up for a high tackle on former team-mate Pedrie Wannenburg.
Then a strong pick-and-drive surge from the Ulster forwards, illegally impaired by the hosts, won the visitors a five-metre scrum which after three collapses from the French front row, evaporated on the fourth attempt with an early engagement from the Ulster front row.
Further injury woe came Ulster's way just before the half-hour mark, as Wilson limped off to be replaced by Henderson, and with the lineout misfiring on several occasions as the half progressed, the prospect of a home quarter-final began to look somewhat distant.
However, a lucky break which saw the Castres forwards accidentally crossing awarded Pienaar a very kickable penalty in front of the posts. The Springbok duly dispatched it to make it 8-6 with five minutes of the half remaining.
Ulster played out the first period in Castres territory, and could even have gone off at the break a point to the good. Antoine Peikrishvili was penalised for collapsing another scrum, yet Pienaar's kick at goal from distance bent too far to the right.
Castres came out of the blocks in the second half much quicker, their experienced winger Marcel Garvey threatening down the left before the Ulster triumvirate of Gilroy, Wallace and Andrew Trimble halted him metres from the line.
After an audacious 50-metre penalty attempt from Kockott dropped just to the left of the posts, the Frenchmen enjoyed a good 10-minute period of sustained pressure, ending with a similarly speculative drop goal attempt from Rémi Tales on the hour.
Then the tide turned somewhat, Gilroy eventually getting some ground to tear up as he led his side into the Castres half.
With Jackson now on in place of Marshall, and Pienaar back to his favoured position of scrum half, Ulster's shape began to look better.
Pienaar kicked his side into the lead courtesy of a central 63rd minute penalty. As the Castres defence began to show signs of faltering, Jackson only just failed to pick out Trimble for a sure-fire try as he broke through with 10 minutes remaining - Tales intercepted at the critical moment.
A superbly-angled Pienaar penalty dropped just short of the posts, but with the minutes ticking down Anscombe's charges were not unduly concerned, as they went about slowing play down in the middle of the pitch.
Stand-in captain Henry in particular was outstanding, contesting every ball and ensuring his colleagues remained focused until referee Nigel Owens eventually brought the contest to a close.
A try-scoring bonus point would have ensured a home quarter-final for Ulster regardless of results in any of the other pools, but in truth the team rarely looked like breaching the Castres defence once, never mind four times.
Although their performance was lacking in some areas, the RaboDirect PRO12 leaders were consummately professional throughout - particularly given the absence of several injured key figures - and their reward was an historic first competitive win on French soil in 15 attempts.
With five victories from six European ties this season, Ulster can look forward to the knock-out stages with confidence - and still a strong chance of home advantage.
|Castres Olympique Score Card|
|Ulster Rugby Score Card|