What do I do if my opponent deviates from theory?


in my chess club, deviating from theory earns you 40 lashes

There is nothing sacred about theory! You must always be prepared to react to the changing situation on the board.

How can you stay with theory if your opponent deviates?
If he deviates try to find the best move in response, there is a reason the move isn't theory, but that doesn't mean that a non-theoretical move is bad. You can't punish all non theory moves. Sometimes you just get a normal position.

Half the time OTB I do that on purpose.
But I guess making reasonable moves that you know are out of book is different from making random (and sometimes bad) moves.
In any case, this isn't something you'll have to deal with only at 1400.
Don't just blindly play your memorized moves. Remember an opening is a sequence by both players.
Having said that, unless the move changes the character of the position, you'll generally be trying to do the same things. Changing the pawn structure is the most fundamental way to change the character of the position. Particularly when the central pawn structure is different, you definitely have to stop thinking in terms of your regular theory.
No. That's a common misconception of newer players.
And even if their move is so bad you do have an advantage, it's very rare you'll be able to punish it right away. Usually punishment from a bad opening comes much later, during the middlegame. So in general just continue development, castling, controlling the center, that sort of thing. If you do, then often by move 20 they'll find themselves in an awkward position, and at that point you can look around for a knockout.
Most of the time, one faces a position with no knowledge of a specific move indicated in a book. One has to accept that as part of chess, and think of opening knowledge as a sometimes helpful aid. After a game, it makes sense to try to look up the moves in a book and see if it has some indication of how one might have played better in the opening.
"... there will come a time, whether on move two or move twenty, when your knowledge of theory runs out and you have to decide what to do on your own. ... sometimes you will leave theory first, sometimes your opponent. Nothing will stop this happening. It happens in every well-contested GM game at some point, usually a very significant point. This is a part of the game: an important part, something you have to get better at. ..." - IM John Cox (2006)

Okay I have read all the comments and it seems that "Theory" is more of a guideline and I should not get too caught up with it. Thanks for your comments I am very new to chess especially theory

Just learn to play chess. If his move in that position (theory) hasn't been played before it doesn't mean anything. Could be good, could be bad, could be equal. Just play the position, the best u can, based on ur understanding.
This answer is short and best.

Just learn to play chess. If his move in that position (theory) hasn't been played before it doesn't mean anything. Could be good, could be bad, could be equal. Just play the position, the best u can, based on ur understanding.
This answer is short and best.
If explaining nothing while spouting truisms is best, then sure, it's great.
I'm not saying he's wrong, but I'm saying it doesn't tell the OP anything.
"His move could be good, it could be bad, just play what you understand, and learn to play chess"
Come on. Even a non player could have wrote that.

Your opinion was just classic. I didn't try to make your opinions less worthy @llamonade - it was obviously classic.

It has nothing to do with my comment. You saw something you agreed with but didn't think to look at it from the OP's perspective.
That's why there's a difference between knowing how to play and knowing how to teach. You can be a good player and not be able to teach s*** unless you can understand their point of view.
As for "classic classic classic" I'm sorry, I didn't realize you were 12. You can like whatever comment you want and I wont say anything lol.