It is program and state specific. In California, for example you have to have your state medical license before finishing 2nd year. In Texas you need a "letter" from the medical board before starting residency. In other states like New York, no licensure is required during residency.
If you want to stay in the state in which you finish residency, you should definitely get your license as soon as you can. If you're at a program that allows moonlighting, you can then make some extra cash at outside facilities, and you can work as soon as you graduate.