It depends on the lender. Some charge to lock the rate, others don't.
If you're ging to use a lender who charges to lock the rate, make sure that they give you a credit for the charge at closing. For example, DiTech.com (owned by General Motors) charges $500 to lock your rate for 30 days. However, they give you that $500 back at closing.
I like DiTech lending a lot. They tell you up front how much closing costs will be, and they guarantee that the costs won't change. They have good rates too.