Is it safe to wear earplugs in flight?
I wear earplugs all the time flying in both pressurized and unpressurized environments, and have done it for many years.  Air pressure changes have no noticeable effect when wearing foam earplugs as the interface between the foam and ear canal is not totally air tight.   The silicone flanged ones made for airline flying have a tiny bleed hole in them (flanged ones are way too uncomfortable for me though). 

If anything, on an explosive decompression, the earplugs would help by delaying the escape of pressure on the outside of the eardrum while the pressure equalizes on the inside through the eustachian tubes, which can take a second or two if you have to work your jaw to open them.

Put them in whenever you want and take them out whenever you want.