All of South Africa's points came in the first half, but despite a mighty effort, Samoa, who were reduced to 14 men when Paul Williams was sent off late on, were unable to keep their last-eight hopes alive.
Bryan Habana scored a ninth-minute try, Morne Steyn added the conversion and a penalty and Frans Steyn kicked a penalty from his own half for the Springboks, who are set to play in the runners-up in Pool C in Wellington next Sunday.
George Stowers' second-half try was not enough for Samoa, who had full-back Williams sent off after 70 minutes for punching Heinrich Brussow.
South Africa also finished the match with 14 men after captain John Smit, on as a replacement, was shown a yellow card for kicking the ball away.
Samoa's failure to get a losing bonus point means they are set to finish third in the pool and Wales should advance as runners-up, barring a major shock against Fiji on Sunday.
Entering the match, Samoa needed at least a losing bonus point and a Fiji win in Wellington to have any chance of progressing, but the Springboks were determined to find their form for the knockout stages in their own uncompromising style.
It was a brutally physical contest and there were a couple of heated off-the-ball exchanges in an absorbing 80 minutes even before cards were shown.
After Morne Steyn missed a drop-goal attempt and Frans Steyn hit the crossbar with a long-range penalty, South Africa broke through.
Habana went over in the corner for his 40th Test try and his 10th in 10 World Cup appearances. Morne Steyn converted.
Frans Steyn kicked a penalty from almost 60metres and Morne Steyn added one from 40m before the centre missed a 62m effort.
A blindside burst by Kahn Fotuali'i almost set up a Samoa score in first-half stoppage time, but Seilala Mapusua's pass went to ground.
A hobbling Habana was replaced by Francois Hougaard after 47 minutes before Samoa touched down.
With Danie Rossouw and Hougaard off the field, both forced into the blood bin, Samoa spread the ball wide and a pass to Williams went to ground.
But it was quickly recycled and Stowers barged over.
Morne Steyn missed a penalty before the Springboks survived after wing David Lemi burst into the 22, only to be penalised for not releasing when it appeared he had not been held in the tackle.
Samoa's chances suffered a blow after Williams was shown a red card for lashing out at Brussow after the South Africa flanker had been held back at a ruck.
Brussow was perhaps fortunate to avoid a spell in the sin-bin, but South Africa also ended the game with 14 men when captain Smit, on as a replacement hooker, was shown a yellow card after 71 minutes for kicking the ball away.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The entire All Blacks apparel line has been updated for 2013/14. Check out the New Zealand All Blacks polo.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Gilbert Blitz 8S rugby cleat is a great cleat at a great price of $69.99. Get a new pair of cleats today.
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
The All Blacks Performance t-shirt is black with hints of blue from the training jersey. Very Cool.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.