Preheat the oven to 350 degrees F (175 degrees C). Grease a 9x13-inch casserole dish.
Melt butter in a frying pan over medium heat; stir in onion. Saute for 2 minutes. Add garlic; saute for 2 more minutes. Remove from the heat.
Mix whole kernel corn, creamed corn, sour cream, stuffing mix, 1/2 of the Cheddar cheese, mayonnaise, salt, and pepper in a large bowl. Mix in sauteed onions and garlic. Pour mixture into the prepared casserole dish and top with remaining Cheddar.
Bake in the preheated oven until stuffing has fluffed up nicely, 35 to 40 minutes.