On VHF/UHF, just ask, "This is [your call sign], is this frequency in use?" If you don't hear anything after five seconds or so, go ahead and use the frequency.
On HF, things are more complicated, because there might be a QSO happening on the frequency, but you might be unable to hear one or both sides of the conversation. In a non-contest situation, it's polite to listen for a while before transmitting anything to hear if someone replies to a station you can't hear. I'd think 30 seconds or a minute would be plenty of time. After that, ask if the frequency is in use; in Morse code, "QRL? DE [your call sign]". If you don't hear anything after a few seconds, go ahead and use the frequency.
One caveat is that you should listen very carefully, because you don't want to "step on" another station's signal, especially a DX station with a weak signal. Unfortunately, on HF it's common for stations to not be able to hear other stations, for several reasons: a station on HF generally can't hear another station inside its skip zone, stations with lesser antennas don't hear as well as stations with better antennas, and urban stations often don't hear very well due to the high levels of local noise radiated by modern electronics.
In an HF contest, things are again more complicated. Contesters should make every effort to not interfere with ongoing non-contest QSOs, especially on the upper ends of the bands where harassed non-contest stations try to use the airwaves. In an HF contest the stations trying for competitive scores want to spend most of their time calling CQ, because QSO rates are generally much higher for "running" stations (stations calling CQ) than for stations that are "searching and pouncing". This puts a premium on open frequencies, especially towards the lower ends of the bands. Contest stations competing with other contest stations for an open frequency use all sorts of tactics that would be considered dirty and underhanded anywhere else.