Wax is produced normally by the cells that line the skin of the ear canal. Under normal circumstances, wax helps to protect the ear canal. However, unfortunately, in some people the amount of wax produced is excessive. This can lead to clogging of the canal and difficulty hearing as you have experienced.
The most important thing when dealing with this problem is not to clean inside the ear with cotton swabs or other devices. This is because these actually just push the wax down against the ear drum, which packs it more tightly and makes it harder to remove. Once this happens, there is little you can do except to go to your primary care doctor
's office, who will be able to remove the wax under visualization.
In the future, to prevent this, it is often helpful to regularly instill drops of warm oil or a commercial wax softening product which you could buy over the counter at your local pharmacy. These work by keeping the wax soft and keeping it from building up in the ear canal. However, the trick is that this must be done quite regularly in order to be of much effect.
Talk to your primary care doctor if you have further concerns.