Petersen, 34, scored 2093 runs in 36 Tests at an average of 34.88.
He hit five centuries and eight half-centuries, with a highest score of 182 against England in Leeds in 2012. He also played in 21 one-day internationals and two Twenty20 internationals.
He said he would continue to play franchise cricket in South Africa and county cricket in England.