Generally speaking, you don't need to worry too much about tips when you're in China. Tipping in restaurants, spas, taxis, salons, etc. is not expected—and it can be a welcome respite for those from countries where it is a real headache calculating how much one should tip.
If you do choose to leave a small tip, like the change from the dinner bill, it is very possible that the staff may give chase to return the money as they will assume you had left it by mistake. In other locations, like Western hotels, a service charge might be added, but again, no tipping is expected.
One exception is when you go on organized tour. No one knows exactly why tipping is expected on tours, but it has come to be the norm. It is customary on tours to tip the guide and driver a certain amount per day. The guide should receive a larger tip than the driver, but both will expect and appreciate the tip.
Of course, if you feel very strongly against tipping, you won't be required to give one. And if you believe the guide or driver were rude or incompetent, then you should report any bad behavior back to the tour operator so they can take the appropriate steps.
How Much to Tip
According to China Odyssey Tours, a tour operator with more than ten years of experience running tours in China, there are guidelines for tipping:
"If you are traveling in a small party like two to four members, we suggest approximately $10 USD per day per person as tips for your tour guide and $5 per day per person for the driver as gratitude for their service. Gratuities can help improve the service for you. Anyone who has received a tip will recognize that his services have been appreciated. For your convenience, we suggest you tip the guide and driver when they see you off at the airport or pier at the end of each city tour."
Roughly, decide how much you want to tip your guide per day as a total. Then multiply that by however many days you've been on the tour (and divide by however many people are in the group. The larger the group, the greater the total daily tip rate should be). When you've arrived at the guide's total, divide by half to get the driver's amount.
Note: This doesn't mean you give half to the driver. For example, if you've decided to give your guide 100 Chinese yuan per day as a tip, the driver will receive 50 Chinese yuan per day.
When to Tip
As for when to give the tip, often you'll find that your guide will see you right into the lobby or into the airport. If this makes you uncomfortable just say directly that you're fine to go inside on your own. Sometimes guides are obligated by their company to see you walk through security.
It's best to tip the driver as you leave the vehicle. Then when you and your guide say your final farewells, hand the guide the tip. If you can let your guide know specifically what you liked about their style, it will help them in the future.
You might have booked a really extravagant tour from your home country and feel that the added gratuity on top is egregious. Before you decide not to tip though, you should speak to the tour operator and ask them what is customary. Don't forget, your guide and driver are probably just simple employees of a larger operation and although you may have paid a lot of money for your tour, your guides and drivers are probably not being paid proportionately.
You may find yourself on a small walking tour or guided tour that you booked through an independent operator. There are many people operating specialized shopping and walking tours (e.g. Francine Martin's shopping tours in Shanghai or Marcus Murphy's adventure tours in Qingdao). Since you are paying the tour fee directly to the operator and there aren't any people in between, it is up to you whether to tip or not.