You're running Go TABLOCK=lock in both cases, so it will only ever lock the tab. @if also needs to be told the command you're testing the argument for (unless it's the Set command, which is assumed if no command is specified).
This would work:
@if:Go TABLOCK=off
Go TABLOCK=lock
@if:else
Go TABLOCK=off
But there is also a command to do what you want in a single line:
Go TABLOCK=lock,toggle
Edit: Some or all of the above may not work back in Opus 10. I've only tested with Opus 12.