It could be herpes, depending on what they look like, but it could also be from shaving. In either case, ulcers like this need to be checked. It might just be something like folliculitis, but may require treatment. If you still have these, please get it checked.