HIV is a sexually transmitted disease meaning you'll need to have sex with someone else before you can get HIV.
Simply masturbating on your own will not cause HIV. Masturbating is a very healthy thing to do and has been shown in studies to decrease cancer.