The first half was a tight affair with chances few and far between. York's Michael Coulson saw a free kick palmed over the crossbar by Exeter goalkeeper Artur Krysiak, but that was as good as it got for the Minstermen.
Exeter's best chance came when Liam Sercombe was played in by Jamie Cureton and he laid the ball across goal for Arron Davies, but the Welshman skied over the bar from inside the six yard box.
York broke the deadlock seven minutes into the second half. Jonathan Smith's pass sent Michael Coulson clear and he showed great feet before firing a shot that Krysiak could not keep out.
Exeter stepped it up and Arron Davies came close with a shot from 25 yards, but with seven minutes remaining, O'Flynn slotted in superbly from Matt Oakley's cross.
Exeter could have won it in the closing stages, but Elliott Chamberlain took too long when through on goal and York got back to clear.