Refractory epilepsy, characterized by seizures that do not respond to standard antiseizure medications, remains a significant clinical challenge. The central role of the immune system on the occurrence of epileptic disorders has been long studied, but recent perspectives on immunometabolism and neuroinflammation are reshaping scientific knowledge. The ketogenic diet and its variants have been considered an important medical nutrition therapy for refractory epilepsy and may have a potential modulation effect on the immune system, specifically, on the metabolism of immune cells. In this comprehensive review, we gathered current evidence-based practice, ketogenic diet variants and interventional ongoing clinical trials addressing the role of the ketogenic diet in epilepsy. We also discussed in detail the ketogenic diet metabolism and its anticonvulsant mechanisms, and the potential role of this diet on neuroinflammation and neuroimmunometabolism, highlighting Th17/Treg homeostasis as one of the most interesting aspects of ketogenic diet immune modulation in refractory epilepsy, deserving consideration in future clinical trials.