The Black Cats went two goals up early in the second half when Nicklas Bendtner and Stephane Sessegnon netted either side of the break before the R's struck back twice via Heidar Helguson and Jamie Mackie in quick succession.
Bendtner opened up the scoring in the 19th minute with his third of the season courtesy of a front post header from Kieran Richardson's corner before things got even better for the visitors when Sessegnon got on the end of the Dane's midfield flick-on to advance into the area, round R's keeper Paddy Kenny, and slot home to double the advantage.
QPR hit back in the 63rd minute when Helguson finished a great move which involved Adama Traore and ended in Alejandro Faurlin supplying a low cross for the Icelandic veteran who bundled home for his seventh of the campaign.
Neil Warnock's men were then on level terms four minutes later with Faurlin chipping into the area for Helguson to head into the path of diving Mackie who nodded past Keiren Westwood after just coming on as a substitute.
But with a share of the points looking likely, Brown got to Richardson's corner to glance in a front post header which was cannoned onto the crossbar from Faurlin on the line and in for the winner to send Sunderland to 15th with their second win in three under O'Neill as QPR's poor home run continues as they drop to 16th as their winless streak stretches to five.
Loftus Road, London - 16,167