Preheat your oven to 375°F (190°C).
In a saucepan, melt butter over medium heat.
Add flour and whisk for 2 minutes to create a roux.
Slowly add milk, whisking continuously until thickened.
Season with salt and pepper.
Spread the béchamel sauce on one side of each bread slice.
Layer ham and cheese on one slice, then top with the second slice.
Spread more béchamel on top of the sandwich and sprinkle additional cheese.
Bake in the oven for 10 minutes or until golden brown.
Fry the egg in a skillet to your desired doneness and place it on top before serving.