Oosthuizen reeled off nine birdies on his way to an eight-under 63, including a tournament record seven in a row from the fourth, to move to 19 under par for the tournament.
It left the 2010 Open champion three shots clear of McIlroy, who returned a tidy 67 to sit alone in second and in striking distance at 16-under.
Woods managed a 68 to move into tie for third with fellow American and Ryder Cup hopeful Dustin Johnson (65) at 13-under.
"It was obviously probably the start anyone would dream of on that front nine," Oosthuizen, who went out in a course record 29, said. "I made everything, so you get those days where you just look at a putt and you hole it."
Oosthuizen started his charge with a tap in birdie on the par five second hole before his game went white hot on the fourth.
He coaxed in a seven-foot birdie putt on the drivable par four to start his blitz.
The 29-year-old drained back-to-back 20-foot birdies on five and six to take the outright lead and when he knocked in a five-footer on the seventh he led by three.
The 2012 Masters runner-up kept the streak alive with a 42-foot bomb on the eighth and impressed when a 23-footer went down on the ninth for an opening 29, a course record for TPC Boston.
The seventh and final birdie of the streak came a hole later when a pinpoint approach left him with a short putt to move six clear of McIlroy.
The South African cooled off on the back nine stringing together six pars before collecting the only bogey of his day on the 17th thwarting any thoughts of a course record 61.
Oosthuizen finished off his spectacular round with a curling 12-foot birdie on the final hole putting him in position to claim his first victory on American soil.
"I've put myself in great spots this year, had a good chance at Houston, had a good chance at Augusta, a few other tournaments, WGC earlier," Oosthuizen said. "I'm just going to keep on doing what I'm doing.
"The more I'm in the position on the back nine on Sunday, or in this case on a Monday, then it's going to happen sooner or later.
"I'm just going to keep on plodding on."
McIlroy, who had increased his overnight lead from one to two with birdies on the opening two holes, found himself six back through 10 despite carding just one bogey.
But the world number one clawed back into contention with four birdies and just one more bogey over the last eight holes.
"You think going out with a one-shot lead and shooting four-under par, that you might still be in the lead going into the last day but Louis put on a display out there," McIlroy said. "It was great to watch.
"Louis is the sort of player that can do that. He's very explosive, and he didn't really put a foot wrong today."
Woods managed four birdies on Sunday with a lone bogey, leaving him six back with a mountain to climb in the final round to claim a fourth win of the year.
"I'm going to have to put together one of those rounds," Woods said. "It won't surprise me if somebody shoots eight or nine under par tomorrow because of where the pin locations are.
"Somebody is going to go out there and do it.
"It may be early, it may be late, who knows, but hopefully I am one of those guys."