Levocarnitine is primarily used to treat primary and secondary carnitine deficiency, particularly in patients with end-stage renal disease undergoing dialysis. It may also be used to prevent carnitine deficiency in individuals whose bodies cannot properly utilize carnitine from their diet.