Umpires Ian Gould and Rod Tucker sanctioned the Proteas after tea when they found a change in the condition of the ball.
Television replays showed Faf du Plessis was rubbing the ball over a zip on his thigh.
The umpires summoned South Africa captain Graeme Smith after the 30th over, changed the ball, and Gould signalled five penalty runs added to Pakistan's total as extras.
Pakistan was 67-3 at the time in its second innings, trying to score 418 to avoid an innings defeat, at least.
Pakistan was at the receiving end during the Oval test in 2006 the last and only time a team was penalized five runs for ball tampering.
Then Pakistan captain Inzamam-ul-Haq reacted strongly and decided not to continue the test in protest before Australia umpire Darrell Hair awarded the game to England — the only forfeited match in the history of test cricket.
This month, the ICC amended its laws regarding the condition of balls, saying "if a player responsible can be identified" the ball will be changed, a five-run penalty will be awarded, and the player responsible will be reported.
It's expected the umpires will lay a charge against du Plessis to match referee David Boon after the day's play, and a hearing held late Friday.
Du Plessis faces a range of penalties; a 50 to 100 per cent fine of his match fees, a suspension from one test and two one-day internationals or two Twenty20s, whichever is played first.Suggest a correction