Normally you should want the termite inspection done before closing.
The Termite companies usually want to get paid before closing
You might want to see the answers to your other queston about Termite inspection fee being part of closing cost. Normally, the answer is no.
You should talk to your escrow officer, and mortgage broker about what are included in the closing cost and get an estimate for closing from your escrow officer to make sure the line items and amounts are correct.