I am in a similar situation. I just miscarried at 10 weeks. During my first ultrasound at 6 weeks, they found a 6cm dermoid cyst on my right ovary. Prior to my pregnancy I had irregular periods and weight gain but they never checked me for cysts. Since my pregnancy failed they want to take my dermoid out through laproscopy before I ttc again. I have been doing a lot of reading and I think the existence of the dermoid caused my irregular cycles, which caused late ovulation, and late implantation, which studies show leads to miscarriage.
I would talk to you doctor but seek to get the dermoid out before your next pregnancy.
This is something your doctor will need to answer. Hope it all works out for you.