Yes — it is against the law to study in the United States without the correct visa and paperwork. Studying in the United States is required for distance students who will attend two weeks of summer residency for two summers. Those without a visa will apply for a F-1 Student Visa. Each visa has different requirements and may or may not allow for incidental study.
If you have a current visa, check to see if it allows you to be a student.