All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
There is no harm for undergoing a medical check up as mentioned in the question provided the doctor does not reveal your 'Awrah (parts of the body that must be covered in Islam) without a necessity. As regards giving him a sample of your sperm in a tube or container so that he would carry out a test on it then there is no harm in this. This falls under what is called seeking treatment and the Prophet said: "Indeed Allaah has not sent down any illness without sending a cure for it, so seek treatment but do not treat yourselves with what is impermissible." [At-Tabaraani]
Extracting sperm should be done only in an Islamicly permissible means, which is through a sexual intercourse with your wife.
Allaah Knows best.