Your loan can be sold at any time. There is a secondary mortgage market in which lenders frequently buy and sell pools of mortgages. This secondary mortgage market results in lower rates for consumers. A lender buying your loan assumes all terms and conditions of the original loan.
As a result, the only thing that changes when a loan is sold is to whom you mail your payment. In the event your loan is sold you will be notified. You'll be informed about your new lender, and where you should send your payments.