Second-half tries from Sean Lamont, Ben Morgan and Jonathan Davies saw the Scarlets celebrate their 100th European encounter with a win, as Stephen Jones also added 13 points with the boot.
Castres' tries came from Marc Andreu and skipper Chris Masoe with Romain Teulet kicking 13 points.
Rhys Priestland, in his first competitive match since the World Cup, kicked a last-minute drop-goal to deny the Frenchmen a losing bonus point.
The Scarlets joined the likes of other seasoned European campaigners Toulouse, Munster, Leinster and Leicester on the 100-match mark and fielded a stellar back line including Wales trio George North, Davies and Jones.
But the Scarlets were fortunate to lead 9-6 at the break against a bigger Castres pack who dominated at the scrum and looked dangerous at the line-out.
Even with a seven-man pack when number eight Joe Tekori was sin-binned for a late tackle on Scott Williams, Castres had the upper hand in the set-piece.
The Scarlets looked more comfortable when the ball was moved wide but let two golden try opportunities go begging through forward passes.
The first saw Scotland wing Lamont go over but the score was disallowed after the pass from full-back Liam Williams, who was preferred to Priestland and Dan Evans.
Castres had nearly taken a dramatic lead from the kick-off but flanker Steve Malonga dropped the ball over the line.
The French side took the lead on two minutes with a penalty for full-back Teulet before Jones replied with two successful attempts on six and 11 minutes.
Teulet kicked his second just two minutes before Tekori found himself in the bin and Jones slotted his third penalty just before the break.
The Scarlets began the second half with real intent and scored the opening try in the first two minutes with Castres still down to 14 men. The region took advantage with Lamont going over under the posts.
Teulet got a third penalty back before the Scarlets scored a length-of-the-field try with number eight Morgan crashing over as the Welshmen led 23-9 on 50 minutes.
But the Scarlets were not able to relax as Castres wing Andreu went in at the left corner. Teulet's conversion reduced the Scarlets' lead to 23-16.
A third try for the hosts arrived 13 minutes later however when Scott Williams raced up the left flank and gave a try scoring pass to Davies. The Scarlets had the final say with Priestland putting over a last-minute penalty.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The entire All Blacks apparel line has been updated for 2013/14. Check out the New Zealand All Blacks polo.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Gilbert Blitz 8S rugby cleat is a great cleat at a great price of $69.99. Get a new pair of cleats today.
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
The All Blacks Performance t-shirt is black with hints of blue from the training jersey. Very Cool.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.