Ben Pearson perhaps had Barnsley's best chance inside the first 10 minutes when he blasted over at the back post, after being found in plenty of space by a teammate.
Reuben Noble-Lazarus fired a free kick over the bar for Rochdale before Andy Cannon fizzed an effort just wide for the visitors.
Barnsley striker Sam Winnall forced Rochdale keeper Josh Lillis into a good save at the end of the half, but neither side were able to find the breakthrough in the opening period.
After the break, Dale were reduced to 10 men when Rafferty picked up his second booking, moments after the visitors were denied by a good stop from Adam Davies.
Josh Scowen gave the home side the lead when he headed home Conor Hourihane's corner low into the corner on 67 minutes.
He then added his second less than 10 minutes later when he once again nodded in a Hourihane's delivery.
Mason Holgate then made it 3-0 inside the final 10 minutes when he finished from six yards out, before Hourihane put more gloss on the result.
Winnall made it 5-0 three minutes into stoppage time with a side-footed finish from close range.
The victory means that the Tykes finish 11th in the League One table, three places below Rochdale.