Can a obgyn write for anxiety meds that are controlled substance?

SURE. Any md or medical doctor can write for an anti anxiety medication. However many are not comfortable doing so for a long term basis due to potential abuse problems. They may refer to a psychiatrist after a period of time.
Ob/Gyn. Depends on justification, their level of comfort, and if it is a one time prescription until the treating physician takes over.