Paul McCallum scored early on for the home side and Craig Reid's penalty doubled the lead four minutes after half time.
The visitors scored through a Scott Davis free-kick, and despite Michael Raynes' red card soon afterwards, substitute Jon-Paul Pittman grabbed an equaliser five minutes from time.
However, Goulding headed in an 87th-minute winner from Danny Rose's free-kick to end the Shots run of six games without a victory.
McCallum gave Aldershot a controversial lead when the assistant referee adjudged that he had bundled Reid's cross over the line despite Damien Batt's attempted clearance.
Peter Vincenti could have made it 2-0 in the 24th minute after a marauding run but goalkeeper Luke McCormick blocked his shot.
Neither side could take advantage of six minutes of injury time after Aaron Morris was carried off on a stretcher after 18 minutes. But when Liam Davis brought down Morris' replacement Adam Mekki after 49 minutes, top scorer Reid dispatched the penalty.
Tensions mounted afterwards as Reid was booked while celebrating the goal and Raynes picked up his own booking for a foul on Reid.
Former Shot Davis's free-kick from just outside the area got Oxford back in the game but Raynes was sent off after receiving a second yellow for cynically bringing down Reid.
And although they thought they had saved a point through Pittman, Goulding was on hand to give the hosts a much needed victory.