As a freelancer, you're in control of when you get paid. So it's important to be clear about your payment terms from the start. You can do this by including your payment terms in your contract or agreement with the client at the start.
I won't sit here and write about how you need a specific type of contract over another, I like to focus on the big picture and in this case it's minimizing risk on your end. There are quite often times nowadays when I don't use a contract, mainly because they can be a large amount of time to draw up and ensure that both parties are fine on the little details.