This would be a good question for a local Realtor. The contract should allow for an inspection period. A good "buyer's agent" should be able to add a contingency to the contract that would protect you and let you retain your earnest money deposit if the inspection results are not to your complete satisfaction. The only out of pocket expense you would incur would be the cost of the home inspection.
Erik if your question is can you protect yourself against costly unknown repairs when writing an offer the answer is yes, if you have written an offer and want out and the seller does not agree to cancel the offer talk to an attorney. There may be dates in the offer that affect your position so don't wait.
Erik, you should seek an attorney's advice regarding your obligations in the contract. Agents/Brokers are not allowed to provide legal advice. The agents/brokers that are providing advice in this forum do not know the terms of your offer and are not licensed attorneys.
Erik, it sounds as if you are currently engaged in a contract. This question may be something you would want to speak with an attorney about. As Agents/Brokers, we are not licensed to advise on legal matters. Best of Luck!