The Welsh region were indebted to a tries from Eli Walker, Hanno Dirksen (2) and Ashley Beck, while 18 points came from the boot of outside-half Dan Biggar.
Treviso scored two tries through Manoa Vosawai and Luke McLean, while Kris Burton supplied seven points with the boot.
Ospreys' Pool Two victory was some revenge for their 12-6 defeat at the hands of the Italian side in the opening game of the RaboDirect PRO12.
Treviso suffered a setback when Alessandro Zanni, their 66-cap Italy openside, pulled out just before kick-off with a back injury.
There had earlier been better news for Ospreys with Justin Tipuric reporting fit despite suffering a hip injury.
Ospreys made a positive start with Biggar kicking three penalties in the opening 15 minutes. He put over his first attempt in the fourth minute after the home side had attacked from the opening two line-outs.
The lead was extended to 6-0 four minutes later when Biggar was successful with a long-range effort after Treviso had transgressed at a scrum as their front eight struggled.
Treviso did get a foothold in the Ospreys 22 but it was immediately snuffed out by some aggressive counter-rucking by the Welsh region, and at the other end the Italians' indiscipline accounted for another penalty which Biggar kicked to extend the lead to 9-0.
Treviso got on the scoreboard with a penalty for Burton on 18 minutes but almost immediately Walker sent the home fans wild with a fine try after weaving his past four would-be tacklers. Biggar converted to give the Ospreys a 16-3 lead.
After a dust-up between the packs referee Neil Paterson sent Wales prop Adam Jones and Treviso captain Antonio Pavenello to the sin-bin.
And Treviso found themselves down to 13 men for two minutes when Vosawai also got yellow-carded after a line-out infringement.
But Ospreys coach Steve Tandy will not have been happy with his side's lapses of concentration at the end of the half which forced them to defend for their lives to preserve their 13-point interval lead.
After regrouping at half-time the Ospreys hit Treviso with a second try four minutes after the break with Dirksen going over in the right corner taking a pass out of the back door from Richard Fussell. Biggar converted as the Ospreys lead was extended to 20.
But Ospreys were then left stunned by two Treviso tries in the space of as many minutes. First Vosawai was on the end of a drive from a line-out before McLean sprinted in unopposed. Burton converted both to cut the home lead to six points.
Biggar stopped the rot on 64 minutes when he put the Ospreys back two scores ahead with his fourth penalty goal.
After hammering at the door for 10 minutes Ospreys scored a third try when Dirksen went over for his second after collecting a chip from scrum-half Kahn Fotuali'i.
And four seconds from the end of time Beck went over for the all-important bonus-point try to end a tricky match on a high note for the region.
Last season's beaten finalists Ulster opened their Heineken Cup campaign with maximum points thanks to Ruan Pienaar's dramatic bonus try in a 41-17 home win over Castres.
The newly-returned Pienaar got down under the posts after Ulster had broken out of their 22 in injury time with the last move of the game.
Ulster's other tries came from Paul Marshall (2) and Andrew Trimble, with Paddy Jackson making a vital contribution of 21 points from the boot on a pulsating night for new Ulster coach Mark Anscombe's side.
It was not all plain sailing for Ulster, though, who lost Stephen Ferris prior to the game with a back injury.
Castres made a brighter start and Romain Teulet slotted a fourth-minute penalty after Ulster were penalised for dragging down a maul.
But Ulster responded three minutes later as Paddy Jackson slotted a straightforward penalty after Castres had strayed offside.
Ulster carved out a try in the left corner from Trimble one minute later.
A Castres high kick went loose and Jared Payne made ground rather easily to set Trimble up for the try.
Jackson then landed a superb conversion from the touchline and Ulster were in front, soon opening up a 10-point lead when Jackson added a second penalty.
Paul Marshall's chip and chase then led to Ulster's second try in the 21st minute, the scrum-half dotting down near the posts to give Jackson an easy conversion.
Castres needed to hit back and Pierre Bernard finally launched a cross-kick left for Marc Andreu to score.
Teulet added the extras but Ulster immediately hit back with Jackson's third penalty after Castres were pinged for not releasing.
Jackson's fifth kick from five attempts was the final score of the half and Ulster led 23-10 at the break.
It was not long before they had their third try, Iain Henderson's surge allowing Paul Marshall to dart over with a blindside break close to the line.
The decision went upstairs to the TMO before Jackson missed his first kick of the night when trying to convert.
He atoned for his miss three minutes later with a long-range penalty that took Ulster to 31-10.
The visitors hit back once more and, after pummelling the Ulster line, winger Marcel Garvey slid over.
Referee Andrew Small went to the TMO before the try was given and Teulet added the conversion.
Ulster's cause was hindered, however, when Tom Court was shown a yellow card for hauling down the Castres maul three minutes before the hour mark.
But Ulster still increased their lead through another Jackson penalty before Pienaar made his first appearance since the Four Nations Championship when he came on for Paul Marshall.
The home side survived Tom Court's binning but struggled to put any more points on the board, even with Castres prop Yannick Forestier being sent to the bin in the 75th minute.
But in the game's final play, Ulster broke out of their 22 when Johann Muller won a ball at the breakdown.
Luke Marshall's break set up Pienaar who showed a lovely swerve and pace to get through the last line of Castres' defence for the bonus try, which Jackson converted.