What could be causing my painful twitches as I fall asleep?

Myoclonus. Propriospinal myoclonus can be painful or not. There are a number of conditions that precipitate. A number of neuologic conditions as well as some primary sleep conditions such as narcolepsy, hypnic jerks (generally not painful), and rls. If this interferes with sleep onset, please seek medical assistance.