A visa does not determine how long you can remain in the United States. This is determined by your current immigration status. Therefore, you may remain in the country beyond the expiration date of a visa as long as your corresponding immigration documents (ie. Form I-20, Form DS-2019, Form I-797, etc.) remain valid and you have maintained your current status.
Once the proper visa expires it will be necessary to apply for a new visa stamp, through the same process as your initial visa application, at a U.S. embassy or consulate when traveling outside the United States. You will need the new visa to be eligible for re-entry to the United States. Applying for a visa usually requires several weeks so you must plan your travel accordingly. If there is a possibility that you may be subject to additional security clearances, additional processing delays should be expected.
It is possible for most international visitors to apply for a new visa in a country that is not their home country. Be sure to follow all U.S. embassy guidelines for applying, and additional wait time is possible if security checks are needed. If you plan to visit Canada or Mexico to apply for a U.S. visa, it is particularly important that you check the Web site of the U.S. consulate to which you will submit your application. You will find instructions about how to make the visa appointment. If you are from one of the countries now requiring additional name check/security screening or in a high technology or technologically sensitive field, you will want to think carefully about applying for a U.S. visa in a third country.