If you are buying a home with a mortgage and are concerned with fees & costs, the first thing you need to do is familiarize yourself with what a Good Faith Estimate is. I have wrote a mini-novel (I am working on a publisher) explaining the GFE, top to bottom, complete detail, at:
It explains how the GFE holds your loan officer responsible for disclosing you the correct fees from the very beginning, so there is very little chance of the "bait & switch" tactics that you have heard where fees start out low and at closing they jump up on you.
But that blog post does not tell you how to avoid working with someone who is going to rip you off from the beginning. In order to do that, I suggest you work with loan officers who have been referred to you by friends, family or co-workers who have purchased a home - if they are recommending their loan officers afterwards then that means they felt they did a special job making the mortgage part of their homebuying experience a good one.
When you speak with your loan officer you'll want to make sure you have a full accounting of the fees. You'll want to ask what type of fees & costs you could expect to incur along the way (credit report, earnest money deposit, home inspection, appraisal fee, closing costs, etc.), how much those costs are estimated to be, and when they are expected to be paid (at the time the service is performed, at closing, etc).
You'll also want to ask what type of loan terms can they offer you if you were to lock in your interest rate today.