Disclaimer: My understanding may be incomplete. Posting this anyway until a better answer is added.
An initial H-1B petition has to specify either change of status or consular processing, so you need to coordinate this with your employer who files the petition. The two methods have different risks and benefits depending on your current status, travel plans, employment plans, and any anticipated delays in getting a visa.
- For change of status, the petition should be filed when you're in the US in a valid status and you shouldn't travel out of the US until it's approved. The petition includes evidence of your current valid status. When it's approved by USCIS and you reach the requested start date, your prior status ends and your H-1B status begins. If you travel after it's approved, you have to get an H-1B visa at a US consulate abroad before you return.
- For consular processing, there is no such travel restriction while USCIS processes the petition. You can be outside the US and/or travel in or out of the US on another status. The petition lists the US consulate where you will apply for an H-1B visa. When it's approved by USCIS, you then have to get the H-1B visa at the US consulate abroad and enter the US with that visa to begin the H-1B status.