Generally speaking, you collect your luggage after immigration (passport) control, but before customs control. However, if you are a transit passenger, you may not have to collect your baggage at all. This depends on which airport/country you are passing through and whether or not a change of airline is involved.