There are generally two types of fees associated with mortgage loans: lender fees and third-party fees. I’ll detail them in reverse order.
Third party fees, as the name implies, are fees paid to third parties. These include the fee for your appraisal, title insurance, the title-company closing fee, recording fees, flood certification, and tax service. All of these involve services associated with a mortgage and get passed along to the borrower. In addition to these, there may be mortgage-related taxes and sales taxes, depending on the jurisdiction. Also, depending on the custom in your locale, there may be an attorney representing the bank for both refinances and purchases. In some places, like Illinois, the parties to a purchase/sale usually choose to be represented by a lawyer who will charge a fee for his or her services.
Lender fees, on the other hand, are what the lender charges for its services in connection with processing and underwriting a loan. These may include an origination fee and an underwriting fee, which a lender may or may not charge, depending on a variety of factors. Suffice it to say that lenders make money by charging a higher rate of interest for the money they lend than for the money they borrow. How they allocate and account for the money they get paid for selling a loan in the secondary market is somewhat complicated and controversial. I’ve written another article that goes into greater depth on the subject.
Hope this information helps.