Bafana Bafana forward Foster came off the bench with 14 minutes of normal time remaining with the scores level at 2-2.
In the fifth minute of added time Foster latched on to a through ball from fellow substitute Hannibal Mejbri before producing a neat finish to give his side maximum points.
The victory was significant for the Clarets as they moved five points clear of the relegation zone.
"I feel amazing, ecstatic and more than anything, I'm happy for the team," Foster said post-match.
"I think we deserved it, especially going two goals up and with the performance we showed.
"I was just blessed today to score the winner. It's an amazing feeling and more than anything I'm just happy for the boys."
Foster will now hope to start in Burnley's next encounter when they host Premier League leaders Arsenal on Saturday.