Depends on the kind of debt. If it is a long term debt (like a student loan, mortgage etc) then khums is wajib on whatever you have remaining after all your expenses at the end of the year.
If it’s a short term loan like day to day then you wouldn’t pay khums.
In case you have to pay, 20% of your savings of which half goes to needy and poor Sadaat whom you can give it to yourself if you choose, the other half goes to your mujtahid or his representative. The Sadaat portion can also go to your mujtahid who would distribute it accordingly.