Welcome to Android Central! What do you mean that it got locked by a code? It's asking you for a passcode? That'd be challenging, since you can't input text on the watch.
Not really sure how it got locked but you can use a paper clip or other sharp object to press the reset button on the back of the watch for about 15 seconds to perform a factory data reset