The game was full of chances but looked destined to finish goalless before O'Nien popped up with a header from Joe Jacobson's free-kick to secure the victory.
The team news didn’t make for happy reading for Blues fans with confirmation that Paris Cowan-Hall will miss the rest of the season with ankle ligament damage, while there was also no return for the injured Aaron Pierre.
Michael Harriman reverted to right-back to pave the way for Matt Bloomfield to come back into the midfield, while Max Kretzschmar started in attack alongside Paul Hayes.
Wanderers began brightly with the midfielders making bright runs from deep, and one such move almost brought about the opening goal on 5 minutes when Kretzschmar, Hayes and Luke O’Nien combined well down the left and Kretzschmar’s low cross found Marcus Bean, who sidefooted wide when well placed.
Moments later Paul Hayes fizzed a shot just wide from 20 yards following a lay-off from O’Nien as the hosts looked to stamp their authority on the game, coming up against a three-man central defence from the Rovers who were without the influential Stuart Sinclair through injury, while top scorer Matty Taylor was dropped to the bench.
It took the Pirates 20 minutes to threaten as Lee Brown volleyed wildly over with his right foot as the ball fell to him in the box, before the hosts were forced into a change when Marcus Bean came off hurt, with Sam Wood taking his place.
Wood was involved in a smart move which resulted in the Chairboys winning a free-kick 20 yards out just past the half-hour mark, and the delivery was curled low towards the bottom corner by Joe Jacobson, only for Steve Mildenhall to parry it behind.
Ryan Allsop was first called upon on 32 minutes to save comfortably from Rory Gaffney’s glancing header as the striker met Ollie Clarke’s initial effort, before Luke O’Nien sent a daisy-cutter into the arms of the diving Mildenhall at the other end.
The end of the half petered out with neither side threatening, other than Jermaine Easter’s shot on the turn deflecting wide off Anthony Stewart. There was also a moment of contention when the referee gave Blues an advantage after Mark McChrystal brought down Kretzschmar, but the official chose not to go back and award the centre-back a second yellow card, having been booked earlier.
There were no changes before the start of the second half, and the first chance fell to Kretzschmar who wriggled past his defender before shooting into the side netting from the left-side of the box.
Jermaine Easter should then have hit the target when he rose to meet a Lee Brown cross six yards out, but the former Blues striker merely glanced it harmlessly wide.
Pirates boss Darrell Clarke then changed his formation to 4-4-2 by introducing Billy Bodin for Daniel Leadbitter, and the game grew in tempo with Paul Hayes hooking a chance at the keeper before Ryan Allsop collected the ball from Lee Mansell’s attempt following a Liam Lawrence corner.
Then Allsop was called upon to tip Ollie Clarke’s powerful drive over the bar, before his opposite number Steve Mildenhall made a fine save to keep out Jason McCarthy’s towering header on the goal-line.
The intensity grew as the game went on, and Ollie Clarke’s shot was deflected wide before Lee Mansell’s overhead kick was comfortable for Allsop.
It took 84 minutes for the deadlock to be broken and it came from a set-piece, as Luke O’Nien beat his man to meet Joe Jacobson’s free-kick and bury a header into the bottom corner.
The celebrations were jubilant but there was still a job to be done, and Ryan Allsop needed to be alert to tip Lee Mansell’s low shot behind at the end of a strong run.
Sam Wood fizzed a volley over the bar from 25 yards in stoppage time but it was the last action of the game as the Chairboys celebrated a popular and much-needed win - their second straight home victory.
Wycombe: Allsop, Harriman, Jacobson, Stewart, McCarthy, Bean (Wood 20), McGinn, Bloomfield, O’Nien, Kretzschmar (Ugwu 81), Hayes.
Unused subs: Richardson, Jombati, Sellers.
Rovers: Mildenhall, Leadbitter (Bodin 56), Brown, Lockyer, J Clarke, McChrystal, Lawrence (Fallon 87), O Clarke, Mansell, Easter (Taylor 67), Gaffney.
Unused subs: Puddy, Parkes, Lines, Montano.
Attendance: 4,759 (1,629 from Rovers)
Winning 50/50 Draw Number (Blue £1): 05251
Prize Money: £668.00
Winning 50/50 Draw Number (Orange £2): 16003
Prize Money: £53.00