Generally, homeowners facing foreclosure are allowed to stay in their home up until the day of the foreclosure sale itself if they choose. After the original loan default, the homeowner is entitled to a certain period of time before a sale can occur. During this time, they have a chance to raise the money to pay off their default debt and thereby retain ownership of their home. The homeowner is allowed to remain in residence at the property during this period.
One of the best ways to get more time to stay in your home after foreclosure, as well as pay off your debt, is to declare bankruptcy. While it may not be the right decision for everyone, a bankruptcy claim puts an automatic stay on all creditors, including your mortgage lender. This means that your foreclosure proceedings will be put on hold for an unspecififed amount of time. If you file for Chapter 13 bankruptcy, you'll also get the opportunity to work out a payment plan with your lender to pay off your debt over the next 3 to 5 years. This means you can remain in your home for as long as the length of the plan, and if you pay off the debt on time, retain ownership of the property.
If the debt cannot be raised however, the homeowner will usually be subject to eviction a short time after a foreclosure sale completes. In some states, the period of redemption following a foreclosure sale may allow the homeowner to remain in the home. It's always best to check your local foreclosure laws to see what your rights as a homeowner are when facing a foreclosure, and to get an idea of when you'll have to leave your home.