The general rule, in taxes, applies: you can only take the deduction in the year you made the payment. In addition, the payment you make must be for the year your student took the classes.
There's one exception: you may claim on your 2021 tax return, a payment you made in 2021 for the first term of 2022. So, if you are billed for the 1st 2022 term, in December 2021, you can choose to pay some of it to get the 2021 credit or wait and pay in January, to claim the 2022 credit (assuming the school is that flexible on paying).