Pull the cable out out of its sleeve and lubricate it. I used white lithium grease when that happened to my old speedo. It, too did what you describe when it was cold.
The grease stopped it but about a year or so later, the speedo itself fell apart and I installed a rebuilt one. If lubricating it doesn't help, leave it disconnected until you fix the head itself.
Your cable might need to be replaced altogether if it's broken or rusty or something.