It depends on whether you are married to the birth mother or not. If you are not married to the birth mother, you can’t find out for sure if you are the child’s father until after the child is born. But your legal obligations to the mother and the child begin at the moment you learn the mother is pregnant. It is important to know that you are expected to provide significant and consistent support to the mother and, by extension, the child while the child is growing in the mother’s womb.
If you are married to the birth mother, you are considered a legal parent and are presumed to be the legal father of the child. If you believe this child is not your biological child, then you have a short period (1 year in some cases) to formally “disavow” (deny any responsibility or support for) the child; otherwise, you could be legally responsible for this child unless you cooperate in the adoption of that child.