The buyer getting a loan to purchase a home must lock his loan rate before loan documents can be prepared. Given typical turn times for preparation of loan documents, delivery to the title company, return of signed documents to the lender for review and funding - the interest rate usually must be locked ten days before close of escrow.
Lenders (nearly unanimously) will not accept a lock until the borrower has a specific property under contract. And the lock (typically) cannot be moved from one property to another in the event the first deal falls through.
When a borrower locks the rate, the lender is guaranteeing that - if and when the loan closes, the borrower will get the locked rate. If rates subsequently move up, the lender's guarantee holds. The borrower's rate will not move up. If rates move down, the lender's guarantee holds. The borrower's rate will not move down. A rate lock is comforting when rates go up and disappointing if rates happen go down. You get what you lock. Consider whether you will be more comfortable locking and seeing rates fall or not locking and seeing rates rise. It comes down to an individual decision.
A rate lock is different than loan approval. A loan can be approved without a rate lock and a rate can be locked without loan approval. But -not all lenders will lock a rate prior to loan approval. So it may make sense to deal only with lenders who can lock in advance of approval.
Some lenders offer a one time "float down" in rate. Meaning that if rates decline, the borrower has one opportunity to take the lower rate. This option normally increases the base (originally locked) rate by 0.125% or so, depending on the type of loan it is.
If rates drop considerably, the original lender may negotiate. But they will not guarantee to do so. If the original lender will not renegotiate, and if time permits, a mortgage broker can move the borrower to another lender who may have lower rates. This can jeopardize the timely close of escrow, but it is possible.
When to lock depends on the borrower's assessment of the direction rates are likely to move and the amount of time remaining before close of escrow. Most buyers lock the rate as soon as they get into contract to purchase. Doing so makes the rest of the transaction considerably more peaceful than floating. But the decision is up to the buyer.