Yes, Socialista, probably castling would have been more productive in the long run, at that time in the game. All white had to do to avoid losing his bishop was: 9...Bgxf6 first, instead of h3. Then: 10. d7xf6 followed by 10...h3.
Playing wrong moves against bad player in hopes of mistake a valid strategy?

You may try playing an inferior move if you believe that the complications may be too much for the other player or if it leads to a pawn structure you think would be much harder for your opponent to play with or some other practical reason. It may be risky to play like this so I wouldn't make a habit out of it. Every blue moon you might consider it but playing that way all the time will probably lead to more losses than anything.

hope chess
Other's have said this too so it may be worth noting Dan Heisman's term "hope chess" is not playing a bad move and hoping your opponent doesn't respond correctly.
Hope chess is playing a move you think may be good, but without checking the opponent's responses at all, and then hoping that there doesn't exist a response that refutes your move. It's an analytical error.

I always expect my opponents to play the best move possible, even if he is rated 500.I'll never play risky or suicide moves in the hope of my opponent making a mistake..A 500 or so-called "weak" player will play the best game of his life once in a while and it could happen when he is playing you or me or anyone..I may make moves like what the op did earlier, but that would probably be due to a blunder or time pressure and it will not be on purpose..When I am playing a game I always expect my opponents to play to the best of their abilities no matter what their rating is, so for me it is not advisable to play risky moves on purpose..
In this game, I made 9...Bg4 with the idea of pinning the knight on f3 and I´m threathening with winning the bishop on g5, white didn´t see it, and I win a piece.
But I´m wondering, if this is just a bad move that was made hoping for a mistake, maybe just continue developing was better?