Saints were already out of contention, while the visitors needed two wins from their final two games to keep alive their chance of progressing.
Castres fought back from 13 points down to level in the second half.
But Tom Wood's try, adding to scores from Teimana Harrison and Stephen Myler, handed Northampton the win.
Leinster became the first team to qualify for the last eight of the competition on Friday, and will progress as Pool Four winners.
The visitors fell behind after only two minutes when Harrison crashed over from close range and Myler converted from the tee.
Rory Kockott landed a penalty for Castres, before they lost Jody Jenneker to the sin bin for a maul infringement, but the French side took the lead for the first time thanks to Alexandre Bias' unconverted try in the corner.
Saints regained the lead through Myler's score and Harrison's second to go in 21-8 ahead at the break.
In a dominant second-half performance, full-back Julien Dumora seized on a gap in the Northampton defence to cross for Castres, and Kockott landed a conversion and two penalties to make it 21-21.
A Myler drop-goal attempt then came off the posts, before Wood went over from a driving maul to earn Saints the bonus point and extend their unbeaten record to five games in all competitions.
Northampton Saints: Ben Foden; Juan Pablo Estelles, Luther Burrell, Harry Mallinder, George North; Stephen Myler, Nic Groom; Alex Waller, Mikey Haywood, Kieran Brookes; Courtney Lawes, Christian Day; Tom Wood (capt), Jamie Gibson, Teimana Harrison.
Replacements: Charlie Clare, Ethan Waller, Paul Hill, James Craig, Ben Nutley, Lee Dickson, JJ Hanrahan, Ahsee Tuala.
Castres Olympique: Geoffrey Palis; Horacio Agulla, Afusipa Taumoepeau, Robert Ebersohn, David Smith; Julien Dumora, Rory Kockott (capt); Mihaita Lazar, Jody Jenneker, Damien Tussac, Loic Jacquet, Victor Moreaux, Yannick Caballero, Alexandre Bias, Maama Vaipulu.
Replacements: Brice Mach, Antoine Tichit, Daniel Kotze, Rodrigo Capo Ortega, Antoine Dupont, Benjamin Urdapilleta, Steve Mafi, Thomas Combezou.
For the latest rugby union news follow @bbcrugbyunion on Twitter.
Northampton earned a bonus-point win over Castres to end the French side's hopes of a place in the European Champions Cup quarter-finals.