If it's an hourly contract: https://support.upwork.com/hc/en-us/articles/211067938-Pay-for-Hourly-Contracts
If it's fixed price: https://support.upwork.com/hc/en-us/articles/211068208-Escrow-for-Fixed-Price-Jobs
re: "Do i pay before or after a job is done?"
The simplest answer is: after.
Your credit card number (or PayPal account) are on file.
When a freelancer logs time on an hourly contract, that time is AUTOMATICALLY billed to your account. AFTER the work has been done.
With a fixed-price contract, your credit card is charged before the work is done, but is held in an escrow account THAT YOU CONTROL. The freelancer submits he work, and then you have up to 14 days to review the work, and you can release the payment at any time. Or do nothing, and let Upwork release it automatically TWO WEEKS AFTER the work has been submitted.
There are are a small number of freelancers who ask to receive payment BEFORE the work has been done. Upwork really doesn't intend for that to be how freelancers are paid. Some of these may be legitimate. Most are scams. Unless you are an experienced client who knows exactly how to handle such situations, you really should just block any freelancers who ask to be paid for their work BEFORE the work has been done.