Yes. You provide a check with the offer. Once the seller accepts the offer, they cash the check and hold the money until the sale closes. There are specific instances where you can get your money back, but make sure you read the contract. You can't just "back out" because you found a better house or because you figured out you didn't have the money to buy the house so your financing falls through. You need to be serious before you put in an offer.
And from the seller's perspective I wouldn't accept an offer from someone who hesitates to provide earnest money. I think they have money problems or they aren't serious about the deal.
I take that back. I would probably accept the offer, but make it conditional on being able to keep my house listed and be able to accept counter offers and back out of the non-earnest money deal if a better offer comes along.
It's inappropriate a buyer to expect the seller to take a house off the market if the buyer isn't serious about buying. You can cost me MONTHS in trying to find another buyer.
You don't ever lose your earnest money. Unless you have made an offer that you don't have serious intention of buying. So, get your financing in order and be prepared to buy the house. Then, in some states your earnest money even earns a bit of interest. So you give $5,000 in earnest, but you get $5500 "back" in closing costs. You generally have to put money down anyway...... so what's the issue?