I've seen a lot of storage methods, but my favorite procedure is as follows:
0. Find some air tool oil at the hardware/lumber store, as advised by others. Mineral oil based, it is designed to prevent rust and not gum up. Do not use typical motor oil that has detergent, as this will rust the engine. WD-40 is not the very worst choice, though it does gum up over time.
1. Warm the engine in an oven at 225 degrees for a few minutes. This helps loosen any oil in it and evaporate any possible moisture. A toaster oven from a thrift shop for $10 is a fairly good choice.
2. Temporarily mount a prop.
3. For a .40, drop about six drops of oil into the intake. If the engine happens to have a throttle carb, do this with the carb at idle and work the barrel back and forth.
4. Flip it over a few times rotating it up and down to help spread oil to the bearings.
5. Let the engine cool. Assess the bearings cold.
6. Oil the crankshaft threads - one drop. A little oil elsewhere on the exterior, like the steel fasteners and the needle valve, is a good idea.
7. Wrap the engine in a paper towel, then enclose it in a plastic bag with most of the air evacuated. The paper towel will serve to absorb moisture. Do not store the engine directly in foam, as the foam will turn to goo and stain the engine. Fox engine boxes are notorious for this.
8. Box the bagged engine in cardboard. This will slow down UV deterioration.
Peter