If the distribution was from an IRA there would not be an early distribution penalty if the distribution is not in excess of your qualified higher education expenses.
If the distribution was from a qualified retirement plan or deferred annuity contract, such as a 401(k), there is no exception to the early distribution penalty when the distribution is used to pay for higher education expenses.