Cook the spaghetti following the instructions for al dente. Drain in a colander. Run cold water over the cooked spaghetti until the pasta is cool. Drain the cooled pasta well.
Pour the well-drained spaghetti noodles into a large 9x13 aluminum food tray with cardboard lid or another freezer container if freezing. If planning to cook immediately use a 9 x 13-inch baking pan.
Add half of the pasta sauce to the noodles and mix in well.
Next, add ¾ of the sliced pepperoni to the tray. Mix until the pepperoni slices are distributed.
Add ½ cup of shredded mozzarella cheese and half of the Parmesan cheese if using and toss.
Top the pasta with half of the remaining pepperoni and half of the remaining cheese.
Repeat the layers of pepperoni and cheese (small containers) until you have used all of the pepperoni and all of the cheese. (If using a 9 x 13 pan you will only have enough ingredients to make one layer on the top.)
Place the cardboard lid on the tray if using and crimp the edges around the pan to secure the lid. Label the tray and freeze up to 3 months. To cook remove the pan from the freezer and thaw in the refrigerator before baking following the directions below.
If baking the Pepperoni Spaghetti immediately preheat the oven to 375 F. degrees. Place the baking pan into the preheated oven and bake for 30 to 40 minutes or until the cheese is melted.
Frozen: Thaw overnight in the refrigerator before baking. Pour off any water that may be in the pan after thawing.