Thank you for you question and sorry your had to wait so long for an answer!
If the mother of your child has permanent residency, they will indeed receive the German citizenship automatically. And as the father of a German child, you qualify for a Aufenthaltserlaubnis t (§28 AufentG) - if you have custody (Sorgerecht). However, in principle, you need a valid visa in order to apply for a Aufenthaltserlaubnis. So you might have to return to your home country in order to apply for a family reunion visa at the German Embassy there.
Depending on your history, there could be a way for you to avoid this and legalize your stay, so I recommend you to contact a lawyer.
I hope this helps, don't hesitate to add a comment if you need additional information!
All the best,