Most cap inspection plans are inherited rather than designed: five pieces per lot because five has always been the number. Whether five is enough depends on the defect rate the plan is meant to catch, and on whether the lot is homogeneous.
Accepting a lot on a sample of five with zero failures gives roughly 55% confidence of detecting a 10% defect rate. To reach 90% confidence at the same defect rate takes about twenty two pieces. Those numbers are worth knowing before a plan is written, because the difference between five and twenty two is the difference between a plan that mostly confirms and a plan that mostly detects.
Caps in a lot usually come from several cavities, heads or assembly stations. A sample drawn from the top of a carton can come entirely from one stream, in which case it says nothing about the others. Sample across streams deliberately, and record which stream each piece came from, so a failure points at a cause.
For safety-related features, and after any lot has been rejected, gauge everything until the process is shown to be back in control. Sampling assumes a stable process; using it on a process that is being adjusted is how bad parts get shipped with a good-looking record.