As Ann mentioned, there are a couple things missing here including the negotiations after appraisal results...
Riverside Real Estate Services
Your loan officer should have explained this to you, but of course most of them are so anxious to tell you that they have a way for you to finance your closing costs they don't explain this part of how it works.
There are a number of things we would need to know in order to help you out. But just like the others have stated you really need to talk to your Agent. But here are the guidelines here in California. If this is a "Standard Sale", meaning not a Bank Owned or Short Sale. In California we have what is called an "Active Removal of Contingencies". The Standard Contract gives you 17 days after acceptance of an offer to complete All of your Inspections, Appraisals, Loan Application and receive and sign off on All of the Disclosures from the Seller. At day 17+, as per the Sales Contract, your Agent should have given you a Contingency Removal to Sign. Normally we as Buyer's Agents don't ask our Buyer's to sign this unless the Listing Agent is demanding it. Once you sign the "Contingency Removal" this is also considering you initialed for Liquidated Damages in the original Purchase Contract as well. At that point you have signed off that you will give the Seller your Earnest Money Deposit should you not perform. There are soooooo many other things to consider here even if you did or did not sign the Contingency Removal. Are you by chance getting a VA or FHA loan? Did you and the Seller sign a contract with the Seller paying your Closing Costs and the new Sales Price at the Appraised Value? These are all factors in if you will get your Deposit back. These are all of the questions and answers your Agent should be able to help you with Lucy. I truly wish I could help you more but I don't know what your contract and any Addendums and/or Counter Offer states. Take these questions to your Agent and she/he should be able to help you. Good Luck!!
Keller Williams Realty