I want to know how far from the airport runways are assigned. Approximately how many nautical miles away or typically how many minutes before landing would the pilot know which runway they'd be landing on? I am specifically interested in large busy airports like DFW, ATL, ORD, etc. Does it vary a lot based on weather and traffic conditions?
At 30-50 miles out, pilots will be listening to the ATIS (or reading it, if Digital ATIS is available), and that will usually list the instrument approach(es) in use. Most importantly, that tells pilots which direction the airport is operating, which might not match the winds since jets can easily operate with a strong crosswind or even a light tailwind. Turning an airport is a giant mess, so they only do it when necessary for safety.
In theory, any flight could be assigned any of the listed approaches. In practice, though, ATC runs major airports so that flights arriving through each arrival gate will usually get the same approach, and ATC will tell pilots to “expect” that approach. For instance, arriving to DFW through the NE or SE gates will usually get you a 17C/35C or 17L/35R approach, and the NW or SW gates a 18L/36R or 13R. (The other runways are mostly used for departures.)
However, if there is a surge of traffic coming in one gate, some flights may be crossed over to balance things out. There is no way to predict that.
Also, nothing stops a pilot from requesting a different approach, and ATC will usually grant it if traffic permits. For instance, a flight that’s running late might try to minimize taxi time by asking for the runway nearest their terminal. They can even request an approach not listed in the ATIS, though that’s much less likely to be granted.
Severe weather can also change things; DFW and a few others are so large that one side may be shut down for storms while the other side pushes planes as fast as possible. Severe weather can also shut down arrival gates, which means the others will see a huge surge in traffic.
The approach isn’t final until ATC clears the flight to execute a particular one, which typically happens 10-20 miles out. It’s a mess for ATC to cancel an approach clearance once issued, and pilots don’t like to switch after they’ve already briefed a certain approach either, which is why there is all that communication ahead of time.
While exact distances & times vary depending on which airport and what runway configuration you're working with, the most reliable answer to the question is, usually on initial contact with the Approach controller.
As an example, here is the SITTH2 RNAV arrival into Atlanta (pdf link):
Inbound to ATL, you'll be cleared for that arrival, and you'll know that regardless of the runway assignment, you can plan to cross SITTH at or above 14,000' and TIZZY at 12,000'. But as far as runway assignment, you're making a best guess. Coming in from the southeast like this, the farthest south runway in ATL, runway 10, would be a fair guess, or the outboard of the 9/27 runways (so, 9R -- since they tend to arrive on the outboards, 9R/27L and 8L/26R, and depart on the inboards) if traffic is light. (Airport Diagram for ATL) But that's not certain until you're talked to Atlanta Approach.
The approach control is the facility that builds the plan to distribute the inbound aircraft (which they can see hundreds of miles out, along with projections when each one will arrive at the "cornerpost" like TIZZY), and they'll have the plan that Delta 123 will get runway 10, Delta 456 will get 9R, American 789 will get 10, and Spirit 987 will get 8L. And so on initial contact with Approach, the crew will be told, typically, to "Descend via the SITTH2, runway 9R". At this point, the crew can update (if necessary) the runway in the FMC, review the approach for that runway, and check that the points in the FMC match what the chart shows (i.e. after TIZZY, going to FRYES and following points for 9R or 10, or to GAASS etc for 8L).
It's not impossible, but it's uncommon for Approach to subsequently change the runway after this, although a crew can always ask. (The exception to this is Denver; they seem to rebuild their plans every few minutes.) If there isn't a lot of traffic, ATC may be able to accommodate a crew's request. In ATL, there isn't a big difference getting to the gate from the north or the south complex; at DFW, it can be a significantly longer taxi, so there are more requests there for "request east side if we can" to try to get a runway corresponding to the terminal where they're parking.
Once the aircraft is on with Tower, it can be possible to switch runways; this is very dependent on traffic and happens only in visual conditions. This would mostly be swapping to an inboard from an outboard runway, rather than from a north-complex to the south-complex (or vice-versa). Atlanta doesn't do this much; in Phoenix, it's pretty common, since the inboard runway on the south side of the airport (25R / 7L) is closer to the south-side gates & doesn't involve crossing a runway to get there, as compared to the outboard runway (25L / 7R, which is typically assigned for inbounds to PHX from the south). If Tower doesn't have anybody getting close to the inboard runway for takeoff, they may offer it to somebody on final. And the crew can ask -- although if there's somebody who's approaching the runway for takeoff, the answer is likely to be "no."