Extension your H1B status can be done in US and you do not have to go to your homeland for that. However if you need new H1B visa stamped on your passport, yes, you have to leave US territory.