O'Grady swung the balance in the Owls' favour with a low drive drive from the side of the box that stand-in West Ham goalkeeper Ruud Boffin should have done better with, but it was veteran stopper Nicky Weaver who was the star of the show.
The 32-year-old, once touted as an England international during his early days with Manchester City, produced a string of fine stops, including a stunning second-half penalty save from Sam Baldock, to keep his side in the game.
This was just Weaver's third game back after missing four months with a knee injury, and his performance was the only real stand-out on an afternoon when, until O'Grady's goal, effort had failed to produce end product.
Before the late drama, Wednesday missed their two best chances through James Tavernier and Jermaine Johnson, while Baldock was frustrated twice by the brilliant Weaver for Sam Allardyce's injury-ravaged side, who can now focus on their attempts to gain promotion back to the Barclays Premier League.
Like Wednesday, they are second in the league, and both teams displayed the sense of freedom belonging to sides whose domestic position is secure.
West Ham's Henri Lansbury was the first to try and make something happen, bursting into the box after six minutes and drilling low across the goal, with Weaver smothering and then watching anxiously as the loose ball reared up and on to the top of his crossbar.
Tavernier then ran on to O'Grady's flick-on, but seemed to panic when he got a sight of goal, dragging his shot well wide of Boffin's goal.
Baldock flashed wide at the other end as both sides looked for an opening, before the Owls' Jermaine Johnson wasted a golden opportunity with 20 minutes gone.
Julian Bennett's pass went straight between the two United centre-halves, Winston Reid and George McCartney, and put the winger through. He took a touch, turned the recovering McCartney and created a near open goal for himself before somehow skewing wide.
Despite the miss, Wednesday gained confidence from it and should have scored for a second time when Danny Batth ran on to a long Bennett throw and headed wide, but the Hammers remained dangerous themselves and Freddie Sears nudged a Lansbury cross just over.
That effort signalled the start of some West Ham pressure which saw Jack Collison test Weaver before the break, and Reid win a penalty after it.
The New Zealand international controlled a loose ball on the edge of the box and, as he turned inside, was felled by Reda Johnson, leaving Keith Stroud little alternative than to point to the spot.
Baldock stepped up and drilled the spot-kick low to the left corner, with Weaver getting down to make a stunning two-handed save.
Buoyed by their let-off, Wednesday went on the front foot and Reid put his body in front of a goal-bound drive from Chris Lines before, at the other end, Weaver and Baldock resumed their personal duel as the former pushed the latter's stinging 18-yard drive on to the post.
Wednesday then saw Bennett taken off on a stretcher after he collided with the woodwork.
The delay led to 11 minutes of injury time, by which point O'Grady had scored.
He raced on to Clinton Morrison's pass, worked his way to the right of the area and fired a drive under the body of Boffin who should have done better.
And, despite the lengthy extension to the game, West Ham could not summon a response, with Frank Nouble lashing over with two minutes remaining.