If the homeowners association has a lien which is not first, then when they foreclose, all the prior, senior liens (such as the one the bank has) survive the foreclosure.
Q: Do i have to pay the mortgage off when I buy the property?
A: Yes, and any other valid liens on the land.