Not every residency requires you to get a medical license. And state licenses are expensive to obtain and renew(unless your residency program reimburses you). So, if you're absolutely sure of the state you want to practice in, you should start applying for a license in the fall/spring of your final year of residency.