Was it bright where you got him out, like in the sunshine? My Jacob does shake his head a bit if it's too bright for him...I think he's trying to focus when his pupils are too small. Just a thought.
it should be nothing to worry about but if he does not stop i highly recommend to go to a vet or to the pet shop to ask. you know just in case i think it is normal if you have only had him for a little while and he is new to you my snakes also did it but now they have stopped. (so i am saying has it been going for a while or not?)
1.0.0 Snow Corn- Diablo 1.0.0 Ball Python 1.0.0 Tri-coloured honduran - Feta (R.I.P. my love!!!You will never be forgoten!)
A video would be awesome - sometimes when you're getting used to having a pet snake some stuff they do can seem a bit odd and at times scary! When you dont know what it is they're doing or why they're doing it can be worrying. When you get used to what's normal for your snake it gets less worrying, it's probably nothing, but if we could see a video then we could tell you if our snakes do it or if he needs a trip to the vets to see what he's up to!