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 in Hambantota.
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.
South Africa had won the first one-day in Colombo by 75 runs while Sri Lanka claimed the second by 87 at Pallekele.
Sri Lanka, who needed their record one-day chase, had promised a positive chase by smacking 57 in the sixth over with Kusal Perera (37) and Tillakaratne Dilshan (30) but a middle order slump saw them lose Dilshan, Kumara Sangakkara (36) and Mahela Jayawardene (two) in the space of just six runs.
When Lahiru Thirimanne went for 22 to make it 151-5, Angelo Mathews (58) and Ashan Priyanjan (30) put up some resistance during their 83-run stand but the target proved too much for the hosts.
For