Hi,
It can be. Since I don't know you had sex with a known or unknown person... whether he may have an infection. I will give information for both sexually transmitted sore and non sexually transmitted infection. 
Sexually Transmitted Infection
-  Herpes is the most common cause, causing a painful ulcer, it can be both HSV 1 or HSV 2 depending on from whom you get an infection. Diagnosed by  HSV 1 + 2 
antibodies panel, IgG & IgM.
-  
Chancroid caused due to bacterial infection, diagnosed by swab from the vaginal region.
-  
Molluscum contagiosum with ulcer and elevations can be clinically diagnosed.
-  Syphilis another bacterial infection, diagnosed by swab test. Early treatment will help you.
-  Genital warts caused due to HPV can be diagnosed clinically. 
-  Non-sexually acquired genital ulceration NSAGU.
-   An aphthous ulcer caused due to 
vitamin deficiency, treatment with a 
multivitamin and anti-inflammatory will help you.
-  Allergy or 
contact dermatitis can be due to sperm allergy, allergy to a condom, allergy to sex toys, soap etc., can be diagnosed by preventing the allergen and anti-allergic medications.
-  Ingrown hair.
-  Infections are due to the open wound caused by sex toys, nails.
-  Scabies, pubic lice caused due to unhygienic sex practices or having sex with a person with bad genital hygiene.
Hope I have answered your query. Let me know if I can assist you further.
Regards,
Dr. S.R.Raveendran, 
Sexologist