If the auction ends due to time or the owner cancelling it, you get your money back. If you get outbid, you get your money back.
When any of these happen, you get an automated message saying "You lost the auction, your bid of 0 gold was returned." You do get the gold you deposited back though.
edit: whoops beaten to it.