Depending on your DM's ruling, a high level cleric can help.
The cleric class skill Divine Intervention may be able to help you, or may not. That will depend on how your DM wants to play it.
Step 1. Find a level 10 (or higher) cleric (most likely an NPC).
Step 2. Persuade or pay the cleric to attempt Divine Intervention to change the Warlock's sex. It's not a sure thing, but it's perhaps worth a try. The key in terms of role playing is to convince the cleric that this is a dire necessity. Where's that party face? Game on! :-)
Beginning at 10th level, you can call on your
deity to intervene on your behalf when your need is great. Imploring
your deity’s aid requires you to use your action. Describe the
assistance you seek, and roll percentile dice. If you roll a number
equal to or lower than your cleric level, your deity intervenes. The
GM chooses the nature of the intervention; the effect of any cleric
spell or cleric domain spell would be appropriate. (SRD V5.1 p. 17; Basic Rules p. 23; PHB p. 59)
The intervention is not explicitly limited to a cleric spell or domain spell ... that's up to the DM. What a cleric will charge you for this service, or demand from you in order to attempt this intervention, is probably a whole different story arc/quest in itself ... again, if you can persuade the NPC cleric to even do this.
At 20th level, your call for intervention succeeds automatically, no roll required.
Whether or not a 20th level cleric exists in your world, or would be willing to do this is all in the hands of the DM.
Based on the criterion for "being able to change back" one then must approach this NPC cleric (after the bouncing baby girl or boy has joined the living) for why it is in the cleric's / deity's interest to revert to former sex.
Some great RP opportunities abound, and likewise more story hooks, payment for services, etc. Speaking of RP, the clerical sort most likely to go for this is probably one with a Trickery domain per the suggestion @Eidolon108 in a comment... though any cleric/deity might see this opportunity to support their aims/agenda. Once again, get that party face to get to work. :-)
Of course, if you are going to this much trouble, you may be able to hire a high level Wizard to cast a wish spell ... at your level those might be hard to come by.