As far as I know you typically need to complete an IM residency to apply for an ID fellowship. That being said it’s an incredibly non competitive fellowship (reimbursement is less than that of primary care for starters), so idk - you could ask your ID PD at your medical school. However I imagine there’s some ACGME rule about it.
Also from a purely practical standpoint you need good IM training to learn and practice ID. Frankly, OB/Gyn (with perhaps the exception of Gyn/Onc, which is still in its own niche) does NOT take care of sick patients. When they consult me on the pregnant patient with rheumatic MS or moderate hypertension they’re very much out of their element. It’s not a dig against them, it’s just that this isn’t what they train to do. IM takes care of truly sick patients and the bang for your buck is going to be in managing those crazy sick septic patients with multidrug resistant organisms or managing the neutropenic fever with fungal endophthalmitis or the guy with valvular endocarditis and an aortic root abscess etc.
I would think long and hard about what you want to do and like to do - and make a choice