I copied this off some random website and cannot vouch for the accuracy of the information, but it sounds similar to what my CPA wife has been telling me.
"Only the earnings portion of a non-qualified withdrawal is subject to a 10% withdrawal penalty
•Distributions are allocated between principal and earnings on a pro-rata basis.
•That means that your withdrawal is divided into contribution and earnings based on the following formula:
•Account Contributions / Account Value x Distribution = Contribution Portion.
•Your contributions (the amount you originally deposited) will never incur penalty.
What are the exceptions to the penalty rule?
•If the beneficiary dies or becomes disabled
•If the student decides to attend a U.S. Military Academy
•If the student receives a scholarship
•In all of these cases the earnings portion of the withdrawal will incur income tax."
http://www.savingforcollege.com/intro_to_529s/what-is-the-penalty-on-an-unused-529-plan.php
This is the downside to the 529, it is strictly intended for educational costs and you will be penalized if you use the money for anything else. Not having to pay the penalty if your kid gets a great scholarship is a nice feature, and you can also spend the money on your own education without the penalty if your kid doesn't use it.