Stokes is facing disciplinary action from the ICC after reacting to abuse from a fan by saying: "Come and say that to me outside the ground, you f****** four-eyed c***".
Stokes’ comment was not shown live, but the local station broadcast it unredacted shortly after.
"I wish to apologise for my language that was heard on the live broadcast today after my dismissal," Stokes said in a statement on Friday evening. "I should not have reacted in that way.
“As I was leaving the playing area, I was subjected to repeated abuse from the crowd.
“I admit that my reaction was unprofessional, and I sincerely apologise for the language I used, especially to the many young fans watching the live telecast around the world.
“Throughout the Tests so far, the support from both sets of fans (England and South Africa) has been brilliant. One incident will not ruin such a competitive series, which we are determined to win.”
England's director of cricket Ashley Giles said Stokes was aware that his reaction was wrong, but spoke of his disappointment at the abuse received by the player and alleged that members of the team's support staff were also targeted.
"It is disappointing that a member of the public has gone out of their way to abuse Ben as he was leaving the field. Ben is fully aware that he should not have reacted in the way that he did and apologises for his actions," Giles said.
“In addition to this incident, members of our support staff were subjected to personal abuse during and after the day’s play.
"We have requested to the venue to ensure that security and stewarding are enhanced for the remainder of the match so that players’ and staff members can go about their duties without provocation.”