My Bank Sold My Debt to a Collection Company. Do I Pay Off the Debt to the Originator or the Collection Firm?

debt

I have heard that even if I pay off the collection firm, I can still be liable to pay off the debt to the bank that originated it. I was told that if I had the means to pay off the debt, I should pay it to the bank, and then tell the collection agency that the debt has already been off and they need to contact the bank to work out the situation. Can anyone tell me if this is the right way to handle this situation?? Thank you sooo much!