Yes. This is called offset, or setoff. Your deposit agreement and loan contract both likely have a clause that says if you owe the bank money and are in default, they can take money they owe you and satisfy the debt. The funds should be debited and applied against the debt.
BankingQuestions.com is a free service made possible by the generous support of our advertisers. Advertisers are not responsible for site content. Please help us keep BankingQuestions.com FREE by supporting our advertisers. When you see an ad for a product or service you may have an interest in, click through to learn more.