You are only infectious from the site of infection. This means that you can only transmit it from site where you have it - if you have oral herpes, you can only transmit it from the mouth, or if you have genital herpes, you can only transmit it from the genitals.
Touching, hugging, and other casual touch does not transmit herpes. If you have genitals herpes, and touch someone else's genitals, you can not spread it that way.