Optus generally doesn't lock phones. If they do they provide an easy unlock option. Google it. If you are no longer on contract then buy the SIM.
If the phone was brought outright (perpaid) then the network is locked ! If you purchase an unlocked Optus prepaid ph, it was say on the display. BUT your amaysim uses optus network that SHOULD work on a locked network. Iv seen comments online of it working. but just for FYI If your phone was on a postpaid plan the network is not locked. If your seeking the unlock code and you brought a prepaid ph outright thats lockd to optus and want it unlocked: it has to be atleast recharched to a accumulated amount of $80.00 and if it hasnt, there is a fee depending how long has the service been active for. less than 6 months = $80 and 6months+ = $25. you can pay/retrieve the unlocking code through: secure-unlock.com.au/ou/launch
Just adding that here is some more info on How to Unlock Your Mobile Device from the Optus Network