Hello. Thank you for writing to us at healthcaremagic
I think you are safe simply because of the fact that this particular sexual act was a protected one.
A condom is good enough to prevent transmission of 
HIV, therefore you have nothing to worry about. 
However, you may take up a screening test for HIV at 1 month post sexual contact, for your own satisfaction. Most likely it would turn up to be negative.
Regarding the painful ulcer which has got you worrying, I believe it is most likely an aphthous ulcer.
You may just use an antiseptic mouth wash, twice or thrice daily.
Topically you may use a topical antiseptic, antibacterial e.g 
chlorhexidine gel, twice daily.
One B-complex vitamin supplement once daily may be added for 2 weeks.
Regards