Melt the butter in a small saucepan over a medium heat, then stir in the flour and whisk to combine. Cook over a medium heat for 3-4 minutes, whisking all the time.
Slowly add the milk, a little at a time, whisking in between each addition. When all the milk has been added, cook for 5 minutes, until the sauce is thick.
Take off the heat and stir in the grated cheese, then leave to one side for 15-20 minutes to cool.
Preheat the oven to 180˚C fan / 200˚C / 356˚F convection / 392˚F.
Line two baking sheets with baking paper / parchment.
Take one defrosted sheet of puff pastry and with a cut into 9 equal sized squares.
Stir the chopped ham into the cooled sauce.
Place a teaspoonful of the ham and cheese sauce in the centre of each of the small squares of puff pastry.
Brush the pastry with either the beaten egg or some milk, brushing all the edges of each square.
Take two diagonal / opposite corners of one square of pastry and bring them to the centre, then bring the other two opposite corners to the centre, pinching in the middle. You don't need to seal all the edges, just the middle point.
Place on a baking sheet then repeat with the other 8 squares.
Brush the tops of each square with beaten egg / milk.
Repeat with the other sheet of puff pastry and other half of the sauce.
Place the filled squares in to the preheated oven and bake for 18-20 minutes until golden.
Leave to cool on the tin for a couple of minutes before serving, as the centres are hot.
Store in the fridge for up to 2 days.