No they don't have to give up the ball at all! The race down a straight track with 4 or 5 hurdles and they jump on a platform that releases a tennis ball. The dog then has to get the ball and run back to you over the same hurdles. It's a relay race and there are 4-5 dogs in a team and they race another team to see which team can bring back the balls the fastest. Each dog get's their own ball.
It's a really fast race and most dogs are Aussies. The smallest dog I've seen race is a Jack Russel.
You can see it here:
http://www.thepetprofessor.com/videos/