Sometimes sterility and infertility can be caused by genetic alteration, so it may be inherited. It can also happen that, although a certain genetic alteration is not inherited, the fact that a parent has had fertility problems can be a risk factor for being sterile. The predisposition of the child to suffer sterility or infertility may be increased even though the cause is not directly a specific genetic alteration.
In any case, it will depend on each situation and the origin of the problem to conceive.