It's hard to have a blanket rule about this one. I've been teaching myself to program the last few months and very recently got to the point where I'm getting paid to code.
It's so hard to gauge your progress as a beginner, and even harder to know when you should be compensated and how much compensation you're entitled to. Startups abusing "internships" to get free labor is a very real thing, and you have to protect yourself.
An example: I accepted an internship that had me pushing live code the first day and provided zero mentorship. The company had more interns than actual employees. I left after just a few days because they were clearly building their company off the backs of unpaid interns, which is really awful.
There are definitely other paths, depending on where you are in your own journey. In my case, an internship hasn't felt necessary. I've been able to leverage my personal projects (mostly front-end development up to this point) to get smaller paid gigs (Wordpress themes, maintaining/fixing sites for smaller companies), and have gotten more calls back each time I add something to my portfolio.
Much of my work has come from personal relationships - whether it's a friend of a friend or someone I meet at a tech event or meetup. It's encouraging to see that being a friendly person can lead to positive things!
The bottom line for me is that if the company thinks your code is good enough for their clients, you should be getting paid.