Purchase your ticket about 6-8 weeks in advance to get the best price. However, we strongly recommend you to wait for your VISA. VISA denial is not supported by cancellation insurance. If you are excepting to get your VISA a few days before leaving and absolutely need to get your flight ticket before, at least wait for receiving the DS-2019 form from your sponsor.
Be aware that you will pass immigration and customs controls in the first US city you arrive. If you have a transfer in a US city, make sure you have at least 2 hours.