Preheat your oven to 375°F (190°C).
In a large skillet, heat 2 tablespoons of olive oil over medium-high heat. Add the chopped onion and minced garlic, and sauté for about 5 minutes, until the onion is soft and translucent.
Add the ground beef to the skillet, and cook, breaking it up into small pieces, until it is browned and cooked through.
Add the diced tomatoes, tomato paste, dried oregano, ground cinnamon, ground nutmeg, ground allspice, salt, and pepper to the skillet. Stir to combine and bring the mixture to a simmer.
Let the sauce simmer for about 15 minutes, stirring occasionally, until it has thickened slightly. If using red wine, add it to the sauce and let it simmer for an additional 5 minutes.
While the meat sauce is simmering, prepare the eggplant layers. Place the eggplant slices in a colander and sprinkle with salt. Let them sit for about 30 minutes to release any bitterness.
Rinse the eggplant slices with water and pat them dry with paper towels. Brush them with olive oil on both sides.
Arrange the eggplant slices in a single layer on a baking sheet, and roast them in the preheated oven for about 15-20 minutes, until they are soft and lightly browned.
To make the béchamel sauce, melt the butter in a saucepan over medium heat. As soon as the butter has melted, whisk in the flour until it gets fully incorporated into the butter.
Start to add the milk slowly. I usually add it in about 4 batches, so add 1/4 of the milk at a time, whisk until all the liquid is absorbed by the flour and repeat until you have whisked in all the milk.
When the sauce starts to bubble, it will be ready to whisk in the pepper and nutmeg. Add the eggs to the sauce and whisk them in well. Stir in the Parmesan cheese, bring the sauce to a boil again and remove from heat.
To assemble the moussaka, spread half of the meat sauce in a 9x13 inch (23x33 cm) baking dish. Arrange the eggplant slices in a single layer over the meat sauce.
Spread the remaining meat sauce over the eggplant layer.
Pour the béchamel sauce over the top of the meat sauce, spreading it evenly with a spatula.
Bake the moussaka in the preheated oven for about 45-50 minutes, until the top is golden brown and bubbly.
Let the moussaka cool for a few minutes before slicing and serving. It is best served warm, but it can also be eaten at room temperature or chilled.