As an H-1B nonimmigrant, you may be admitted for a period of up to three years. Your time period may be extended, but generally cannot go beyond a total of six years, though some exceptions do apply under sections 104(c) and 106(a) of the American Competitiveness in the Twenty-First Century Act (AC21).
Your employer will be liable for the reasonable costs of your return transportation if your employer terminates you before the end of your period of authorized stay. Your employer is not responsible for the costs of your return transportation if you voluntarily resign your position. You must contact the Service Center that approved your petition in writing if you believe that your employer has not complied with this requirement.
[Source: USCIS]