In the proclamation on the family, the First Presidency and Quorum of the Twelve Apostles stated: “All human beings—male and female—are created in the image of God. Each is a beloved spirit son or daughter of heavenly parents, and, as such, each has a divine nature and destiny. Gender is an essential characteristic of individual premortal, mortal, and eternal identity and purpose.” From this we are assured that male and female reproductive organs will remain in their proper place as gender identifiers for all eternity, worlds without end.
Misled people can make use of all the science and surgery they can to change these identifiers in mortality, but in the next life beyond the veil they will see that they still have the same essential characteristics they were born with to those same heavenly parents in their pre-existent home. God our Eternal Father is a perfect being with all knowledge and all power and he knows how to put a male spirit in a male body and a female spirit in a female body and he has never made one mistake in this regard in all the history of the world; nor will He ever. For those rare incidents of nature or other intervention, where some confusion (on our part) is present with these organs, if nothing sorts them out before then, death certainly will. Surgery cannot affect the eternal spirit found within the body of a man or woman in any way.
But there is a further question as it relates to the resurrection: will those sexual characteristics/organs be functional—will they be operative? The revelation says: “In the celestial glory there are three heavens or degrees; And in order to obtain the highest, a man must enter into this order of the priesthood [meaning the new and everlasting covenant of marriage]; And if he does not, he cannot obtain it. He may enter into the other, but that is the end of his kingdom; he cannot have an increase” (D&C 131:1-4). These verses constitute the settled doctrine of the church, that those who are resurrected with any kind of body other than an exalted glorified body in the highest degree of the Celestial Kingdom, will not be able to have increase, or spirit children—a continuation of the seeds: “Therefore, when they are out of the world they neither marry nor are given in marriage; but are appointed angels in heaven, which angels are ministering servants, to minister for those who are worthy of a far more, and an exceeding, and an eternal weight of glory. For these angels did not abide my law; therefore, they cannot be enlarged, but remain separately and singly, without exaltation, in their saved condition, to all eternity; and from henceforth are not gods, but are angels of God forever and ever” (D&C 132:16-17). This is the eternal law.