There are different ways, but generally it would be upon a signal, and then either with a time limit or not.
One of the most common would be for one of the seconds (chosen by lots) to give the signal, and then count to three. The duelists had to fire within that window, or else they forfeited their fire. Less refined duels might not have the explicit count, but nevertheless had the understanding you ought to fire quickly and without taking the time to aim. This was especially popular in the US and UK, and was used with the Hamilton-Burr duel. Less common ways would be with no time-limit following the signal being given. This might simply mean standing there and taking your time to shoot (mostly a German thing), or actually advancing on each other - this would generally involve starting marks far apart, and a barrier that they could go up to. The first person to fire couldn't leave the spot they shot so it made for an interesting calculus. You see this in the US, especially the antebellum West like Missouri, and Germany again.
A final note, that the gunfights in the 'Wild West', were not duels in the traditional sense, lacking the regulation by seconds. To be sure, the frequency of the old 'High Noon' shootout was far below what pop culture would make you think, but in the very few fights which conform to the general image, such as Hickok-Tutt, there was no signal to be given, and it was simply be started by someone going to draw their gun.