Unused contribution room for TFSAs gets carried forward each year, so you're not under any strict deadlines to contribute by a certain date. That being said, if you'd like your contribution to be counted in 2021 for tracking purposes (so your CRA profile gets updated), you should initiate your deposit by December 31st, 2021.
If you are planning on making a withdrawal and would like the corresponding contribution room from the withdrawal to be added back as of January 1st, you'll need to initiate the withdrawal request on December 27th or prior.
For example, if you are planning on making a withdrawal for $10,000, but would like that $10,000 back in contribution room come January 1st, 2022 - you should initiate your withdrawal by December 27th, 2021 in order for it to be completed by year-end.
What if I missed the contribution deadline?
TFSA contribution room carries forward year after year, so don't fret if you didn't make your deposit prior to December 31st!
If you missed the withdrawal deadline you'll still get the corresponding contribution room back! It just will not be added until January 1st of the following calendar year.