When you leave, you will typically be given information on your options for your 401k plan. Generally, you have a few options:
1) Leave it in the plan (not all companies allow this option)
2) Cash out (pay tax and potential penalty if under certain age)
3) Roll over to an IRA or your new company retirement plan (if it allows rollover contributions)
You will need to check your specific plan rules to determine how things like company profit sharing contributions are handled (it is possible there is a vesting schedule on these which means you could forfeit that value if you leave prior to vesting). You can get a lot of info on your plan's specific rules in the Summary Plan Description which your employer should provide to you.