Preheat the oven to 375 degrees F (190 degrees C).
Melt cream cheese and butter in a saucepan over medium heat. Mix well. Add flour and milk; stir well. Cook, stirring constantly, until thickened, 6 to 8 minutes.
Remove saucepan from heat; add corn, green chiles, salt, and pepper. Mix well. Pour into a casserole dish.
Bake in the preheated oven until bubbly, 30 to 40 minutes.