Technically, you don't HAVE to make a deposit--earnest money--when making an offer. However, your offer generally won't be taken seriously unless you do. The amount will vary depending on: (1) purchase price of the house, and (2) local customs. In some places, it's sometimes generally a flat amount, like $1,000 or $2,000. Other times, it may be a percentage of the value of the house--such as 1/2% - 1% of what you're offering. Your Realtor can advise you.
If someone else makes a better offer and the seller accepts the better offer: No, you won't lose your deposit. You CAN lose your deposit, though, if: (1) You make an offer, (2) The offer is accepted, and (3) You fail to comply with the terms of the offer. For example, you offer $100,000 and accompany it with a $1,000 earnest money deposit. The offer is accepted. Then you change your mind and decide that you've paid too much, or you don't want to move. Or the contract requires you to apply for financing within 7 days, and you don't do that. In those cases, your deposit would be at risk. Again, your Realtor can advise you.
Hope that helps.