You need to go to JAG and get their help. They can guide you, but not represent you. You will have to get a lawyer where ever your ex is filing for custody to represent you in court. You are going to have to prove that you have made good arrangements for your son while you are deployed as I'm sure this will be the basis of his claim for custody. If you have a good lawyer, he will be able to argue that you have taken all the necessary steps to insure that your child is well cared for in your absence. You will need to provide documentation and your lawyer will also bring into play that fact the your ex has not supplied any form of child support or taken advantage of whatever visitation that has been given him. Your lawyer will also be able to play on the very fact that why he originally didn't take custody or volunteer to take care of his son during this deployment nor demand his rights to have custody of him while you were deployed. If you have a good lawyer, you will have nothing to fear.
What lies behind us and what lies before us are tiny matters compared to what lies within us.