The H-1B visa has an annual numerical limit, or cap, of 65,000 visas each fiscal year. The first 20,000 petitions filed on behalf of beneficiaries with a U.S. master’s degree or higher are exempt from the cap. Additionally, H-1B workers who are petitioned for or employed at an institution of higher education (or its affiliated or related nonprofit entities), a nonprofit research organization, or a government research organization are not subject to this numerical cap. Cap numbers are often used up very quickly, so it is important to plan in advance if you will be filing for an H-1B visa that is subject to the annual H-1B numerical cap. The U.S. government’s fiscal year starts on Oct. 1. H-1B petitions can be filed up to 6 months before the start date, which is generally April 1 for an October 1 start date.
So to sum it up I’d say apply the first chance you get (April 1st – as stated above) so you have multiple chances; the 1st year during your OPT and then when you get your STEM extension after that you’ll have another shot.