Usually at the graduation ceremony when people get together at convocation of the institute. In Pakistan it is not a strict legal requirement. It is rather an optional thing. Many never take the oath simply because they are not around when convocation happens (eg. being abroad, etc.). PMDC registration does not require an oath. It just needs a medical degree from a recognized institute. This said, oath is not everything. It is the culture that promotes the humanity which by extension also penetrates medical community. Even a strictly administered oath is not enough. People do treason all the time when under oath. So it is how a doctor is trained and how students are selected into medical colleges that matter. You admit people on the basis of how much money their corrupt daddy has made or you train them in a poor environment then you get the result as such with or without oath specially in a society in which even the corner shop sells stuff while swearing to his God (in effect taking an oath) that the merchandise is genuine while it is not. You see where it is going now. An oath does not equip a doctor with knowledge, compassion, modern equipment and drugs and a comfortable salary to make him work for his patients.
One funny thing I have heard about Thailand which might or might not be true is a tradition at a medical college there. On convocation when they administer the oath all new doctors then are locked in mocked coffins and left there for 2-3 hours. This is to make them realize what their mistakes would feel like personally. This said, also I have to say that mistakes happen all over the world. A medical research study in US has shown that 30% of all deaths in US happen because of a medical mistake or negligence somewhere during patients lives. The most important thing is not the doctor. It is to have a very well funded, well organized and very centralized form of health care. Oath does not improve health care. It is the system that does (eg. see Scandinavian health models). In Pakistan a junior doctor in public sector is paid 200 dollars a month and is worked like a donkey. You can not get much with this amount of reward-ship, specially when you realize the condition of hospitals are no better than doctors themselves, being under equipped and under stuffed in addition to being over burdened.