You would pay tax on the earnings portion of whatever amount you take out for a non-qualified purpose. All 529 distributions are done on a pro-rata basis. For example, if you have $50,000 in a 529 account, $35,000 of which is contributions and the balance of $15,000 is earnings, 30% of any non-qualified distribution would be subject to tax (and the penalty as well, unless a penalty exception applies).
If you make a non-qualified distribution payable to your child, and depending on the child's other income for the tax year, it's possible that there would be no tax to pay after applying the standard deduction.
Edited to add: I don't think the 10% additional tax ("penalty") can be reduced by any deduction, so that should be taken into account.