Most of the time, you're going to be working with someone who has some insight into the residency process, either because they've been advising for years, or because they're involved with that school's residency.
But, at my school, you don't get a residency adviser until you're in your fourth year, once you know what you want to do, and you use them to figure out what electives to take during fourth year. I imagine each person's experience is a little different, depending on what specialty they go into and how popular it is at that school. For instance, I plan on going into peds, and one of the faculty who is frequently an adviser has several friends who are the directors of pediatric residencies across the country.