Some cats will commonly get ear infections.
You will need to see the vet to be sure that the eardrum is intact and to have the ear cleaned out. It sounds like he has a severe ear infection and might even have a hematoma if the ear flap is sticking out like a pillow. If he doesn't have a hematoma yet, he might soon get one because the head shaking and rubbing will commonly cause a blood vessel to burst in the ear. This requires surgery to fix so you will want to take care of this as soon as you can. Try to keep him from shaking as well as you can.
Hot compresses are fine to ease the muscles around the ear but don't put anything in the ear canal until you find out what you are dealing with.
The problem with ear infections is that they can be bacterial or fungal in nature. If you put the wrong medication in the ear, you can actually do more harm than good so you want to be sure of what you are dealing with before you put anything in the ear.
Let me know if you need more help.
Oral antibiotics are not going to solve the problem if the ear drum is not intact or if the issue is fungal. If you use the wrong medication, you can do much more harm than good.
If money is a problem for you, you might want to look into www.carecredit.com. They offer financing for even the smallest vet bills.