Preheat oven to 350 F. Place potatoes into a large saucepan and cover with water. Bring to a boil over medium heat, let simmer until fork tender. Drain.
Melt butter in a large saucepan over medium heat. Cook onion until softened. Add in flour and cook for a minute to brown. Pour in milk and season with salt and pepper. Continue to cook over medium heat, while whisking constantly until thickened.
In a large bowl, mix potatoes with diced ham and sauce, spread mixture out into a large greased baking dish. Top with cheese and bacon. Bake for 25-30 minutes.