Apple doesn‘t publish the details on this. According to a HowToGeek article, it‘s three days
When an AirTag is away from its owner for longer than three days, it will emit a sound in the hope that someone will find it. This duration is set by Apple and may be changed in the future via an over-the-air update.
(Source) but I also found comments indicating that it has been reduced to 24 hours by Apple.
The distance is defined by Bluetooth at the end which covers about 30 meters. If a tag moves out of Bluetooth range of its owner (and outside of the areas the owner has defined as „do not alert“), it is considered to be „away“ and may emit a sound.