Quins had only pride to play for in the fifth-round Heineken Pool 4 match, but led 3-0 after 20 minutes and trailed 11-8 after 50 minutes.
However, the last half an hour was one-way traffic as the Castres players queued up to score.
The victory moves Castres to 16 points and second place in the group, but they face a daunting trip to the Gnoll ground in Neath next weekend.
Sixteen points will not be enough to qualify as one of the two best runners-up, so coach Christophe Urios’ men need a win in Wales to secure a berth in the final eight for the second time in four seasons.
The game kicked off in perfect conditions at a half-full Stade Pierre Antoine, and Harlequins opened the scoring with an Andy Dunne penalty.
The diminutive fly-half’s well-struck goal was the only scoring of the opening quarter as the two sides renewed acquaintances between the two 22-metre lines.
Castres began to take control through the boot of Laurent Marticorena (two penalties), and scored the only try of the half through flanker Rodrigo Capo Ortega to take an eight-point lead into the break.
Quins full-back Gavin Duffy brought his side back to within three points with a well-taken try early in the second half, but the 50-minute mark signalled the start of one of the worst periods in the English club’s history.
Hooker Remi Vigneaux was first over the line, followed by scrum-half Alexandre Albouy and replacement back-row Romain Froment.
Capo Ortega scored his second before Quins skipper Luke Sherriff stemmed the flow with a five-pointer of his own, but a second try to Froment and one to fellow back-rower Guillaume Bernad turned the match into a romp.
In the final minute, former Test winger Ugo Mola snatched an interception and was able to walk the ball across the Quins’ try-line.
The whistle will blow on Quins’ European run when they play Munster at Twickenham next Saturday.
CASTRES: Metcalfe; Raffault, Marticorena, Denney, Mola; Delaigue, Albouy; Reggiardo, Vigneaux, Galasso, Nallet, Spanghero, Bernad, R Capo Ortega, Volley.
Replacements: Argenese, F Capo Ortega, Deen, Froment, Dourthe, X Sadourny, Morlaes.
HARLEQUINS: Duffy, Harder, James, Deane, Keogh, Dunne, So’oialo, Jones, Tiatia, Dawson, Rudzki, Miall, Molitika, Sherriff (capt), Hortsmann.
Replacements: Dott, Muggeridge, Easter, Diprose, Staunton, Reay, Williams.