Preheat the oven to 350°F. In a large skillet over medium-high heat, cook and crumble the ground beef along with the onion. When the beef is done and the onion is tender, drain as needed, and stir in the corn. Transfer the meat mixture to a bowl.
Return the pan to the stove over medium heat and add the butter. When the butter melts, add the flour and whisk smooth. Slowly add the chicken broth and then milk, whisking constantly. Bring to a simmer, while continuing to whisk the mixture, until the sauce thickens (about 8 minutes). Add ½ teaspoon salt and ½ teaspoon pepper, taste and adjust as desired.
Grease a 10-inch baking dish, about 2.5 quart size, with butter. Place about a third of the potatoes in a layer in the bottom of the pan, sprinkle with salt and pepper, top with half of the meat mixture, followed by about a third of the sauce and another sprinkling of salt and pepper. Repeat and then finish with a final layer of potatoes and the remaining sauce. Sprinkle with salt and pepper.
Bake until the potatoes are tender, about 60-70 minutes. When the potatoes are tender, remove from the oven, top with cheese and continue baking until cheese melts, about 6-8 minutes. Serve warm.