You should continue paying the rent. Just because the home goes into foreclosure, does not mean the owner will lose the home, especially these days. If the home has been sold at auction, you should find out who the buyer was and see if you can negotiate to stay in the property. The house may have been bought by the bank or may have been bought by an investor. They would rather have an occupied house right now while they try to sell it or until the market picks up and they can sell it.
Once title has vested in or reverted to the financial institution/lender, your lease should be terminated and you will likely either have to move from the house or be evicted. Until that happens, however, you will be expected to continue to pay whatever rents are due under the lease. As to whether you get a return of your security deposit, such a determination will likely depend upon the condition of the house at the time you vacate the premises and should have nothing to do with the foreclosure action.