how to get rid of pimples under the skin

Wash the area. This will remove extra oil and dead skin that could further irritate the pimple and contribute to the growth of bacteria.[3] The pimple will probably be sore, so use a soft washcloth to wipe gently with warm water.
Wash at least twice a day. Do not scrub hard. The hair follicle is already stretched from the infection and you don’t want it to rupture.
If you use soap, use a mild, oil-free, water-based product. Oily soaps may leave a film that can contribute to clogging your pores.
If the pimples are in an area where your hair can reach them, use hair clips, a ponytail, or braid to keep your hair off your face. Your hair can transfer oils to your skin and make them worse. If you cannot keep your hair away from the area, wash it so that it will have less oil to transfer to your skin.[4]

Do not touch or squeeze pimples under your skin. Because it is not open to the air, it is somewhat protected. If you touch or squeeze it, you will cause the skin above it to burst open.
This will cause an open wound which is more vulnerable to infection and scarring.

Don’t irritate the pimple with lots of sunlight. Sunshine can trigger outbreaks in some people. If you are more likely to get pimples when you are in the sun, protect the area with a non-oily sunscreen or moisturizer with sunscreen in it.[5]
In addition, sunlight can cause sunburns, aging of the skin, and increases your risk of skin cancer.
This is especially important when the sunlight is strongest. This includes near the equator, at the beach where it also reflects off the water, and during the summer months. Even when it is cloudy, UV rays still penetrate the clouds, so you still need to protect your skin.
If you are worried the sunscreen will aggravate your pimples, wear a hat instead, but remember your neck and parts of your face may be exposed.

Go without makeup or use only oil-free cosmetics. Makeup can also mix with the oil on your skin to clog pores. The safest route is to not put makeup on the pimples. But if that is not an option, look for products that say noncomedogenic on the label. That means that they won’t form a plug in your pores. You’ll want to choose water- or mineral-based makeup. [6][7]
Oily, waxy foundations are more likely to seal the bacteria and dirt into the pimple. Then as the bacteria multiply, the pressure will grow in the pimple and it is more likely to pop out as a whitehead or blackhead.
Do not sleep with your makeup on. Cleanse your skin before bed so it will have a chance to rest and breathe. This will prevent bacteria from building up.