Jacques Kallis hit a half-century to help South Africa defeat Australia by 25 runs in Cape Town.