The following information is taken from IRS Publication 519 Please note that optional practical training is considered to be "full time student" status.
Students and Exchange Visitors
Generally, services performed by you as a nonresident alien temporarily in the United States as a nonimmigrant under subparagraph (F), (J), (M), or (Q) of section 101(a)(15) of the Immigration and Nationality Act are not covered under the social security program if the services are performed to carry out the purpose for which you were admitted to the United States. This means that there will be no withholding of social security or Medicare taxes from the pay you receive for these services. These types of services are very limited, and generally include only on-campus work, practical training, and economic hardship employment.
Social security and Medicare taxes will be withheld from your pay for these services if you are considered a resident alien as discussed in chapter 1, even though your nonimmigrant classification (“F,” “J,” “M,” or “Q”) remains the same.
Services performed by a spouse or minor child of nonimmigrant aliens with the classification of “F-2,” “J-2,” “M-2,” and “Q-3” are covered under social security.
Nonresident Alien Students
If you are a nonresident alien temporarily admitted to the United States as a student, you generally are not permitted to work for a wage or salary or to engage in business while you are in the United States. In some cases, a student admitted to the United States in “F-1,” “M-1,” or “J-1” status is granted permission to work. Social security and Medicare taxes are not withheld from pay for the work unless the student is considered a resident alien.
Any student who is enrolled and regularly attending classes at a school may be exempt from social security and Medicare taxes on pay for services performed for that school.
The U.S. Citizenship and Immigration Services (USCIS) permits on-campus work for students in “F-1” status if it does not displace a U.S. resident. On-campus work means work performed on the school's premises. On-campus work includes work performed at an off-campus location that is educationally affiliated with the school. On-campus work under the terms of a scholarship, fellowship, or assistantship is considered part of the academic program of a student taking a full course of study and is permitted by the USCIS. In this case, the educational institution endorses the Form I-20. Social security and Medicare taxes are not withheld from pay for this work unless the student is considered a resident alien. [Emphasis added]
Students in “F-1” status may be permitted to participate in a curricular practical training program that is an integral part of an established curriculum. Curricular practical training includes work/study programs, internships, and cooperative education programs. In this case, the educational institution endorses the Form I-20. Social security and Medicare taxes are not withheld from pay for this work unless the student is considered a resident alien.
Employment due to severe economic necessity and for optional practical training is sometimes permitted for students in “F-1” status. Students granted permission to work due to severe economic necessity or for optional practical training will be issued Form I-688B or Form I-766 by the USCIS. Social security and Medicare taxes are not withheld from pay for this work unless the student is considered a resident alien.
Students in “M-1” status who have completed a course of study can accept employment for practical training for up to 6 months and must have a Form I-688B or Form I-766 issued by the USCIS. Social security and Medicare taxes are not withheld from “M-1” students' pay for these services unless the student is considered a resident alien.
In all other cases, any services performed by a nonresident alien student are not considered as performed to carry out the purpose for which the student was admitted to the United States. Social security and Medicare taxes will be withheld from pay for the services unless the pay is exempt under the Internal Revenue Code.
Exchange Visitors
Nonresident aliens are temporarily admitted to the United States as nonimmigrant exchange visitors under section 101(a)(15)(J) of the Immigration and Nationality Act through the sponsorship of approved organizations and institutions that are responsible for establishing a program for the exchange visitor and for any later modification of that program. Generally, an exchange visitor who has the permission of the sponsor can work for the same reasons as the students discussed above. In these cases, permission is granted by a letter from the exchange visitor's sponsor or by endorsement from the program sponsor on Form DS-2019, Certificate of Eligibility.
Social security and Medicare taxes are not withheld on pay for services of an exchange visitor who has been given permission to work and who possesses or obtains a letter of authorization from the sponsor unless the exchange visitor is considered a resident alien.
In all other cases, services performed by an exchange visitor are not considered as performed to carry out the purpose for which the visitor was admitted to the United States. Social security and Medicare taxes are withheld from pay for the services unless the pay is exempt under the Internal Revenue Code.
If you are a “J-1” visa holder, your spouse or child may be permitted to work in the United States with the prior approval of the USCIS and issuance of Form I-688B or Form I-766.
Nonresident aliens temporarily admitted to the United States as participants in international cultural exchange programs under section 101(a)(15)(Q) of the Immigration and Nationality Act may be exempt from social security and Medicare taxes. “Q-1,” “Q-2,” and “Q-3” visa holders are aliens whose employment or training affords the opportunity for culture-sharing with the American public. They are allowed to work in the United States for a specific employer in an approved cultural exchange program. The employer must be the petitioner through whom the alien obtained the “Q” visa. Social security and Medicare taxes are not withheld from pay for this work unless the alien is considered a resident alien. Aliens with “Q” visas are not permitted to engage in employment outside the exchange program activities.