If the sales price you are offered falls short of the amount you owe the lender -- called a "short sale" -- you need to get permission from your lender. This is because in most states, technically a lender is allowed to sue you after the house is sold (or foreclosed on) to recover any remaining deficiency -- the difference between the sales price and what you owe on the mortgage. In most cases, however, a lender is not likely to sue for a deficiency.
If you live in a state that doesn't allow a lender to sue you for a deficiency, you don't need to arrange for a short sale. In this case, if the sale proceeds fall short of your loan, the lender can't do anything about it.
Short sales usually aren't possible if there is a second mortgage, unless the same lender owns both loans. Also, some homeowners may be better off letting a foreclosure take place, saving a few month's mortgage payments until it happens. For more information on short sales, see Nolo's article Short Sales and Deeds in Lieu of Foreclosure.