Depends a little on whether you owed the money (as far as Optus was concerned). If so getting it back is a process. If its just an accidental charge then just contact Optus directly and reequest a credit. After accounts are closed Optus should send outstanding money to you.
You can just cancel the Direct Debit in MYACCOUNT or ask them on LIVECHAT. You can also do it directly with your bank. They may say they don't want to but they definitely can.
Have you checked your last bill? What are the dates on the bill? e.g. if you ported out on May 11th and your last bill says it's for May 1 - May 31, you would still need to pay an amount for May 1 - May 10. Was the amount debited the same amount advised on the bill?