Left-hander De Kock smashed a 127-ball 128 while skipper De Villiers hit a fiery 71-ball 108, making a century off just 66 balls, as South Africa posted their highest total against Sri Lanka of 339-5 in windy conditions at Mahinda Rajapaksa Stadium.
The Proteas then restricted the hosts to 257 in 44.3 overs for their first-ever one-day series win on the island by 2-1. Angelo Mathews top scored for Sri Lanka with 58.
South Africa had won the first one-day in Colombo by 75 runs while Sri Lanka claimed the second by 87 at Pallekele.
This is Proteas first win in 21-years since they began their tour to Sri Lanka in 1993.
The two teams will play a two-test series starting at Galle from July 16.