Brentford struck after just 21 seconds to set up their seventh Championship win in nine matches at Huddersfield.
Sergei Canos fired the Bees ahead, but Jamie Paterson slotted in an equaliser shortly after half-time.
Scott Hogan latched on to Konstantin Kerschbaumer’s through ball to restore the lead before the pair combined again for the striker’s second.
Substitute Lasse Vibe smashed in after replacing Hogan, and John Swift capped Town’s misery with a late fifth.
Brentford’s excellent late season run of seven wins from their final nine matches took them away from danger and up to a ninth-place finish.
The Terriers, who won just one of their final eight games, ended the campaign in 19th, three places above the relegation zone.