How long does the DNS cache last in Mac OS X?

You can flush the local DNS cache with the following command:

dscacheutil -flushcache

How long a DNS entry is cached typically depends on the TTL of that DNS record, which is configured by the DNS admin of the relevant hostname.

You can find out the (remaining) TTL of any given DNS record with the dig command:

dig apple.stackexchange.com

In the answer section you'll see the remaining TTL right next to the hostname (in this example 257 seconds).

;; ANSWER SECTION:
apple.stackexchange.com. 257    IN  A   198.252.206.16