The Ospreys, with fly-half Matthew Morgan controlling the game, were twice reduced to 14 men in a bad-tempered first half and were put under pressure up front.
But Morgan kicked four out of four first-half penalties and centre Sonny Parker picked off a pass from Russia wing Vasily Artemyev to score on the stroke of half-time.
Northampton responded, though, and Calum Clark added to Hartley's double and Artemyev's first-half score to turn the game around.
South African flanker Francois Louw scored on his debut as Bath maintained their impressive progress in the LV= Cup with a seven-try 46-13 thrashing of Worcester which sees them top Pool 1 with a maximum return.
Josh Drauniniu crossed for Worcester with Joe Carlisle booting two penalties and a conversion.