Zoloft is used to treat depression, obsessive-compulsive
disorder, panic
disorder,
anxiety disorders, post-traumatic stress
disorder (PTSD), and premenstrual dysphoric disorder (PMDD).
Lexapro is used to treat anxiety and major depressive disorder.
As you can see Zoloft is used to treat OCD whereas Lesapro is used to treat anxiety, so that is why your doctor recommended trying Zoloft.
You can give it a try and if it is ineffective, talk with your doctor about alternatives.