My question is, when is it ok to underpromote, I sometimes do, but only when I even/win material, or put my opponent in check.
To help illustrate my point, I offer the following game:
Under-promotion is an interesting concept in chess. It is not very common, but when used appropriately, it can be very useful. This is also something you would not want to do without a very good reason. The concept of under-promotion is like your boss asking you to take a promotion in your job and you refusing it. You would never do such a thing unless something worse is going to come out of that promotion that would outweigh all the positive factors.
It is always nice to have examples and I am glad you provided one with your question. We will first establish some pointers that can help us decide if an under-promotion is a good thing to do and then we can evaluate the under-promotion in your game.
Under-promotion would be a very good thing to do if one of the two following conditions were to be true:
If the piece you are planning to under-promote is going to be of more use than a queen. In this case the under promotion obviously has to be knight, because a queen can also move like a bishop and a rook.
If promoting to a queen is going to make the situation worse. The main cause for such a situation would be a possibility of stalemate.
I hope these pointers and the examples give you a clear idea of when you would want to under-promote. Now think about the under-promotion from your game. As you had mentioned in your comment, it is definitely a cool thing to do, but it was not really necessary. However it was not bad either since in this case it did not matter what you promoted that pawn into, it was just about to be captured anyways.