It’s hard to give a specific time or mileage figure because the life of the filter depends on how much crud it ingests. A filter that lasts 20,000 or even 30,000 miles on a vehicle that’s driven mostly on expressways may last only a month or two in a rural setting where the vehicle is driven frequently on gravel roads. Changing it annually or every 15,000 miles for preventative maintenance may be a good recommendation for the city driver, but not its country cousin.
Regardless of the mileage or time, a filter should be replaced before it reaches the point where it creates a significant restriction to airflow. But when exactly that point is reached is subject to opinion.
A slightly dirty filter actually cleans more efficiently than a brand new filter. That’s because the debris trapped by the filter element helps screen out smaller particles that try to get through. But eventually every filter reaches the point where it causes enough of a pressure drop to restrict airflow. Fuel economy, performance and emissions begin to deteriorate and get progressively worse until the dirty filter is replaced.
Many heavy-duty trucks have a "restriction" meter on the air filter housing that signals when the filter is dirty enough to need replacing. But lacking such a device, the best you can do is guess.
Removing the filter and holding it up to a light will show you how dirty it is. If it’s really caked with dirt, it obviously needs to be replaced. Trying to shake or blow the dirt out is a waste of time because too much of it will be embedded in the filter fibers.
NOTE: Many filters that appear to be dirty are in fact still good and do not really need to be replaced. So it’s up to you. If you think it’s dirty, replace it. If you don’t think it’s dirty enough to need replacing, then don’t.