Theoretically you can change your study course as often as you wish but practically there are a few rules that govern this simple act.
This stipulates that foreigners living in Germany having a student visa may only change their study courses twice.
The first time you can change your study course anytime and to any course. This simply means you can change from studying Mathematics in your 7th Semester to studying Art or music for example.
The second time you can only change between your first and third semester and only to a subject that allows you to carry the acquired credit points. E.g. from Sociology to Political Science or any other group of subjects that share the first 2-3 Semesters.
If it’s your first time changing your study course and you decide to change from one end of the spectrum to the other; remember you’ll be applying for the new study course as a “new” student and rules like NCs (Numerus Clausus) and your high school and bachelor certificates will play a role in whether you get a position or not.
If you change within the same department, there’s less stress in most Universities though they will require you fill in some forms and talk to relevant authorities to allow you to change. If you’re lucky this will be a walk in the park. If not, it could be a disaster but don’t let that stop you.
Also, I’d advice you avoid changing your study course around the same time you are renewing your visa. Finally, talk to the officials before you make the leap. Let them advice on how viable your plans are and whether or not it is possible to make the move you want to make. This could also mean you visit neighbouring universities to discuss this issues beforehand. DO NOT, try and apply a month or two right before your visa expires.