The Iron arrived in south Wales on Saturday having lost 10 of their last 12 league games and in second-bottom place in the table.
They looked to have held on for a hard-earned point until Olofinjana rose to nod in a left-wing cross from Bluebirds substitute Jason Koumas.
On-loan Arsenal youngster Jay Emmanuel-Thomas made his third start for the Bluebirds but Peter Whittingham missed out with a dead leg.
Scunthorpe made two changes to the side who were thumped 5-1 at home to Hull last weekend.
On-loan Chelsea defender Ben Gordon came in for Andrew Wright and Josh Wright replaced Bobby Grant in midfield.
Cardiff dominated the opening exchanges and in the sixth minute a cross by Paul Quinn was greeted by a firm header from Jay Bothroyd which flew wide.
The hosts threatened again in the 12th minute when Emmanuel-Thomas drilled in an 18-yard shot which missed the target.
Bothroyd then hit a free-kick from 35 yards which Scunthorpe's Sam Togwell did well to clear.
In the 21st minute a dangerous cross by Craig Bellamy was cleared by Michael Nelson as the hosts sought to make the breakthrough.
Six minutes later, the hosts went close again when Emmanuel-Thomas hit a fierce shot from 20 yards which Josh Lillis did well to parry clear.
Bellamy, who scored the winning goal in last weekend's win against Swansea, then warmed Lillis' hands before Olofinjana had a shot blocked by Nelson.
Cardiff threatened within eight minutes of the restart.
Andy Hughes fouled Emmanuel-Thomas and Bothroyd's free-kick flew narrowly over the crossbar.
Moments later Aaron Ramsey hit a shot from six yards which Eddie Nolan blocked and moments later Cardiff made a tactical switch as Chris Burke replaced Emmanuel-Thomas.
In the 59th minute, Bellamy crossed dangerously and Michael Chopra headed goalwards from 12 yards.
Lillis saved comfortably and then Cardiff's Kevin McNaughton drilled in a 20-yard shot which missed the target.
Burke then missed from distance as the Bluebirds struggled to make their opportunities pay.
Scunthorpe failed to create many opportunities themselves but they showed enough quality in defence to suggest they could hold on for a precious point.
Ramsey had a shot blocked by Paul Reid and Iron striker Joe Garner saw a 25-yard shot go narrowly wide.
However, the hosts finally made the breakthrough with five minutes remaining when Koumas swung in a fine cross.
The ball reached Olofinjana who swooped to head into the top corner from 12 yards out.