In the embroidery world, getting a finished article of clothing embroidered depends on whether it can fit on an embroidery hoop. They do come in a lot of sizes, but it would be difficult, just as an example, to embroider on the rear pocket of slacks because they aren't very wide or deep.
Most clothing where you see embroidery on a small area (and headwear embroidered on the brim) is embroidered before the garment or hat/visor is sewn together. Technology is always advancing, but do keep the placement in mind. Socks typically have logos woven in (or in some cases, put on as an applique).