Nuno! I struggled with this for a time. But I'm far more comfortable buying underthings now that I was when younger - as you get older, you care less what people think. But for now, I have a couple of suggestions:
(a) find a store (such as a Walmart if you have those) that has self-checkout lanes. Grab a 5 pack of panties (make sure you have the right size/style that you want), put them in your basket, then put another item on top if you are afraid of people seeing. When you check out, scan the panties first and quickly stick them in the bag, then put your other item/s on top.
(b) When you go into the store, have a shopping list with you. You walk up to the panty wall with your list in hand - if someone approaches you and asks if you need help, you say "I'm a little embarrassed and I'm not sure what I'm looking for, I was told to get THESE (panties) and some other things for my mother/sister." If no one approaches you, you still look at the list as you are checking out the colors and sizes, you refer back to your list....people walking by will think someone sent you on an embarrassing errand but that you are a good person.
(c) Amazon delivers pretty much anything right to your door. If you are worried that someone else at home would open the package - you tell them: "I'm expecting a package and it has a gift in it for: ________ (girlfriend, mother, whomever) and I'd prefer you didn't open it yet."
(d) Amazon again, you can copy/paste the order to a word file, and alter it. Order panties, and when they arrive - if someone opens it and confronts you - you show them the phony order (that you printed ahead of time) showing that you ordered men's underpants - and that Amazon must have messed up ans sent you women's - then you threaten to send it back or whatever. Make a big deal out of Amazon sending the wrong thing, etc.
I've used all of these tactics, now I just walk in and buy what I want. If anyone asks or approaches me, I'll say "where do you keep the gift bags and greeting cards?" this lets them know that I am buying a romantic gift for a special someone (they don't need to know that special someone is ME).
Most people who work in retail stores really don't care. You will be long forgotten by the end of their shift. Don't worry about it.