Best idea I'd say is to go to a good guitar teacher, or an experienced player. Chances are that there is something slightly wrong with your body alignment and position when you play.
You could try to fix it yourself by feeling the pain, and then playing more slowly, being conscious of the pain and relaxing your shoulder until it subsides - it's probably general tension. A teacher or more experienced player could probably spot the problem straight away, but correcting a bad habit may take some time....
Good Luck.....
Check out my music, video, lessons & backing tracks here![br]https://www.renhimself.com