O'Hanlon, who is on loan at the County Ground with a view to completing a permanent free transfer switch, did his chances of a full-time move no harm by putting the home side in front in the 33rd minute.
Striker Tommy Mooney headed Brian Howard's corner back across the face of goal for the full-back to send a diving header beyond the reach of goalkeeper Carl Muggleton and inside the right-hand post.
Muggleton had already had to move swiftly off his goal line to prevent midfielder Matt Hewlett from giving Swindon the lead in the 17th minute and the only mystery was why it took Andy King's side until the 86th minute to make the game safe.
O' Hanlon could have twice added to his tally in the second half but sent headers over the cross bar when well placed as Chesterfield failed to manage a single shot on Swindon's goal to leave them perilously placed above the relegation zone.
Swindon captain Andrew Gurney was inches away from adding a second goal with an 84th-minute free-kick which had Muggleton beaten. But the home crowd only had to wait another two minutes to see their side extend their advantage.
O Hanlon was again instrumental as he flicked on Howards corner at the near post for striker Sam Parkin to volley home his 16th goal of the season.
Swindon boss King said: "That was one of our best performances of the season because we knew Chesterfield would make it tough.
We never looked in trouble at the back and we kept our discipline and shape well in the second half which we wouldn't have done this time last year." Chesterfield manager Roy McFarland admitted: "If we perform like that over the remainder of the season then we are going to find it hard to pick up points."