You should know it because you decide it on the client side and viceversa.
Each "command" sent from client or server has an id, which is string, example "fireBullet", "move", "jump" etc... For each of these requests you should decide if you want to send them with TCP or UDP. This is not dynamic, it's planned beforehand.
Whenever you can compensate for the loss of one or more packets you can use UDP, and whenever you need the guarantee that a message will be delivered you use TCP.