Heat the vegetable oil in a large pan over medium-high heat. Add the diced beef and brown it on all sides. Remove the beef from the pan and set it aside.
In the same pan, add the chopped onions and minced garlic. Sauté until the onions become translucent.
Add the sliced mushrooms to the pan and cook until they release their moisture and start to brown.
Sprinkle the flour over the mushroom and onion mixture, stirring constantly for about 2 minutes. This will help thicken the filling.
Gradually pour in the beef stock and red wine (if using), stirring continuously to avoid lumps.
Stir in the tomato paste and Worcestershire sauce. Season with salt and pepper to taste.
Return the browned beef to the pan and add fresh thyme or rosemary sprigs if desired. Reduce the heat to low, cover, and simmer for about 1 hour or until the beef becomes tender and the sauce thickens. You may need to add more stock or water if the mixture becomes too thick.
Preheat your oven to 200°C (392°F).
Transfer the beef and mushroom mixture to a pie dish or individual ramekins.
Roll out the puff pastry on a floured surface to fit the top of your pie dish or ramekins.
Place the pastry over the filling, and trim any excess. You can use the extra pastry to decorate the top if you like.
Make a small slit in the center of the pastry to allow steam to escape during baking.
Brush the top of the pastry with a little beaten egg or milk for a golden finish.
Bake in the preheated oven for about 30 minutes, or until the pastry is puffed up and golden brown.
Remove from the oven and let it cool for a few minutes before serving.Enjoy your homemade steak and mushroom pie!