Thanks for joining!
This is a tricky one because it 'seems' like it comes and goes.
I wonder if she's sleeping on it the wrong way? or maybe there's an issue with the muscle itself or the joints/tendons/ligaments and walking aggravates it - then sleeping calms it.
Just speculation on my part though. A vet visit would obviously be best here.