buying a house switching homeowners insurance how soon after

How soon after you buy your home can you switch insurance providers, what happens to the money you may have prepaid, and what does your lender need to know?