In general, you are awarded frequent flyer miles or points for a flight after all stages of the flight have completed, and if you have been aboard for all stages of the flight. For our purposes here I am defining "flight" as a scheduled trip that has been assigned a single flight number.
You can expect this regardless of how many total flights are in your itinerary, so if you are flying COS-DEN-MUC-JNB, you might already have credit for your COS-DEN flight by the time you land in JNB. At the same time, in the unlikely event you deplane at an intermediate stop on a direct flight, you might not get any credit for even the part that you have flown.
The time it takes between completing the flight, having the miles deposited, and having status or other benefits triggered by those miles recognized varies by carrier, especially when you are dealing with credit from partner airlines. "When will my miles post?" is an extremely frequently asked question on FlyerTalk. It's important to remember that loyalty programs are a function of the airline's marketing department, not its operations. Miles don't get added in real time to your account; rather, there are processes that sweep the list of completed flights and corresponding accounts to be credited, and sometimes records can be delayed and miss a sweep.
According to American's FAQ, AAdvantage miles are credited
- For airline travel: Travel on American is credited to your account 1–3 days from your date of travel. Allow 15 days for credit from other AAdvantage partner airlines.
- For other partner transactions: Miles earned from other AAdvantage partners are generally credited within 30 days. Occasionally, miles will take longer to post.
For air travel and United Mileage Plus,
Mileage and Premier qualifying credit (where applicable) should be reflected in your account within 48 hours after travel is completed.…
For flights on Star Alliance member airlines and other partner airlines, it may take up to 7 days for mileage and Premier qualifying credit (where applicable) to display in your account…
As for Delta, they do not provide it in a FAQ, but the Request Mileage Credit form states
Most flights will be posted to your account within 24 hours of the flight. However, some partner airline flights may take up to 7 days to post.