It was an important result for Birmingham who began the day level on points with their opponents.
The home side played for the majority of the second half with 10 men after Shaw was shown a second yellow.
Wednesday caretaker manager Neil Thompson made three changes following the midweek defeat at Stoke.
Liam Palmer, Matt Penney and Josh Windass replaced Osaze Urhoghide, Adam Reach and Jordan Rhodes, who all featured among the substitutes. Shaw retained his place despite signing a pre-contract agreement with Celtic.
After a quiet start, with neither side carving out a chance inside the opening quarter of an hour, there was a great opportunity for the hosts when Callum Paterson found Tom Lees whose shot from the centre of the area was straight at keeper Neil Etheridge.
Barry Bannan put a header on target, but it lacked the power to trouble Etheridge.
Wednesday were reduced to 10 men five minutes after the restart when Shaw was shown a second yellow card after fouling Maxime Colin.
There was a chance for Birmingham when Sunjic set up Bela who fired in a low shot which was saved by Westwood at his near post.
The goal came when Hogan got on the end of a low driven ball into the area by Bela to guide the ball past Westwood.
Palmer then came to side his side's rescue, nipping in to turn the ball away as Hogan prepared to pounce following a low cross from Gardner.
Kadeem Harris also produced an important interception as San Jose shaped up to shoot following a ball from Hogan inside the area.
Etheridge had to be alert to tip over an in-swinging corner from Barry Bannan.
The keeper then produced a superb save to keep out a close-range header from substitute Jordan Rhodes as Birmingham climbed out of the relegation zone.