While purposeful ejaculation of semen outside of a woman’s body or into a condom is generally prohibited as a violation of wasting seed, it is permissible when performed for the constructive purpose of helping to enable a couple to conceive.
As you note, there are two main options for collecting semen, through relations with a special condom or through manual stimulation. While some halachic authorities prefer the option of collection via relations, others, including our site’s rabbinic supervisor Rav Yehuda Henkin, maintain that both alternatives are equally permissible.
Even at the lab, semen collection via relations with a condom is permissible, as long as the room is private. However, your discomfort with having relations there is understandable. If you choose that option, bringing your own sheets and turning down the lights can help make the situation more comfortable.
If you choose the alternative, manual stimulation, then either you should stimulate your husband or he should use his non-dominant hand or a thick glove, so as to further distance the act of collection from the prohibition of spilling seed and to distinguish it from masturbation.
Please let us know if we can be of further assistance to you. You may also find it helpful to arrange a free consultation with a Yoetzet Halacha Fertility Counselor, details here.
This response was updated on 4 June, 2020.