My little boy had to hold my hair to go asleep from the time he was about one until he was 4 or so. He'd also bite, chew, suck and pull, which drove me crazy. I know this isn't what you're asking but for us, the solution was to offer alternative sensory stimulation such as a chew toy to bite on, fidget toys to hold, terry cloth bedsheets, a warm grapeseed cushion on his tummy, and a long massage every night before going to sleep. I managed to wean him by offering another round of massages for every five minutes that he could go without touching my hair. At first he couldn't go for longer than a few seconds - it was almost as if his hand had a will of its own, sort of like in the Addams family lol. He then managed to go longer and longer. He still likes stroking or nozzling it occasionally when we cuddle but is able to stop, or change what he is doing when I ask him to.
I also told him that it hurt me if he used me like a fidget or chew toy, that I was a person and not a thing, offered cuddling positions that were pleasant to both of us while stressing that this was what cuddling should feel like (ie pleasant to both, a valuable life lesson I think in case he ever, heaven forbid, should be on the receiving end of "cuddling" he feels uncomfortable with), and redirected him to whatever "thing" was helpful at the time. This depends on your relationship and how strong your discomfort is with what he's doing of course. At the time, this and other sensory behaviour seriously hurt our relationship - I remember he also started sucking my nose! We'd also just had DD and for some reason, DS appears to ramp up sensory seeking behaviour in fall and winter, getting better again in spring). He did develop a tic that involved pulling his own hair at the time, which went away in spring. (It's recently reooccurred, together with some "hair-seeking" behaviour, but nowhere near as bad as it used to be and redirection has worked so far).
Good luck!
Edited to add that I had a number of threads right about this time last year, with lots of helpful inputs by others, so you may want to check those out using the search function.
Follow Mothering