Recent studies find that sugar tastes less intense to humans with obesity, but whether this sensory change is a cause or a consequence of obesity is unclear. To tackle this question, we study the effects of a high sugar diet on sweet taste sensation and feeding behavior in Drosophila melanogaster. On this diet, fruit flies have lower taste responses to sweet stimuli, overconsume food, and develop obesity. Excess dietary sugar, but not obesity or dietary sweetness alone, caused taste deficits and overeating via the cell-autonomous action of the sugar sensor O-linked N-Acetylglucosamine (O-GlcNAc) transferase (OGT) in the sweet-sensing neurons. Correcting taste deficits by manipulating the excitability of the sweet gustatory neurons or the levels of OGT protected animals from diet-induced obesity. Our work demonstrates that the reshaping of sweet taste sensation by excess dietary sugar drives obesity and highlights the role of glucose metabolism in neural activity and behavior.