。
Lately I've been getting leg cramps while sleeping.
Literal
Recently sleeping-when leg-cramp [object-を] cause.
こむらがえり (leg cramp, literally 'calf reversal') is a somewhat specialized health term — こむら is an old word for the calf muscle (腓). ~てる is the casual contraction of ~ている marking an ongoing state, and ときに sets the temporal condition. を起こす with medical conditions means 'to develop a symptom.'