You need to file I539 to change your status(not visa). Download the form(I539) and read the instrcutions in it, http://uscis.gov/graphics/formsfee/forms/i-539.htm.
It depend on which center process your petition. Normally, 3 months in advance is reasonable. If you are working using the EAD of OPT, you cannot work when you receive the approval notice(I797).