There are different kinds of hypnosis. In therapeutic settings traditional, or classic, hypnosis is differentiated from modern, Ericksonian hypnosis.
Traditional hypnosis, as it has been used from Mesmer to Freud, is based on direct commands. The hypnotist usually acts in a dominant manner and uses eye contact, pendulums, fixation of the index finger etc. to induce the trance. Advantages of traditional hypnosis are quick induction of trance and often a quick deepening of trance. Disadvantages are that not everybody is susceptible to this kind of hypnosis. Show hypnotists use traditional hypnosis, but they preselect their subjects to work with those susceptible to direct commands. Direct induction is also popular in the context of NLP.
James Braid explains the eye fixation method of trance induction in Neurypnology (1843):
Take any bright object (I generally use my lancet case) between the
thumb and fore and middle fingers of the left hand; hold it from about
eight to fifteen inches from the eyes, at such position above the
forehead as may be necessary to produce the greatest possible strain
upon the eyes and eyelids, and enable the patient to maintain a steady
fixed stare at the object.
The patient must be made to understand that he is to keep the eyes
steadily fixed on the object, and the mind riveted on the idea of that
one object. (p. 27)
James Braid inducing a trance with the eye fixation method
Ambroise-Auguste Liébeault, founder of the Nancy school of hypnosis in the 19th century (distinguished from the Paris school around Charcot at the Salpêtrière), used eye contact to induce a hypnotic trance in his patients. (Kossak, 2004, Hypnose: Lehrbuch für Psychotherapeuten und Ärzte, Weinheim: Beltz, p. 22)
Modern or Ericksonian hypnosis, developed during the 20th century, mainly by Milton H. Erickson, does not use any auxiliary means. Trance is induced indirectly during conversation. The client falls into trance slowly and without noticing. Advantages are a pleasant feeling during trance and a better acceptance than during traditional hynosis. Also, a dialogue with the unconscious is easier in modern hypnosis. A disadvantage is that the trance is usually not very deep (usually a medium depth).
Therapists often use a combination of both methods to utilize the advantages of both methods.
To answer your question, while eye contact is unnecessary – Milton H. Erickson, in Hypnotic Realities, says that "often the therapist does not even look at the patient's face" –, it is one of several methods for inducing quick and deep trances in suitable subjects.
I don't know that there is an "optimal eye locking duration", as the time to fall into trance – and thus the time of fixation, if the eye fixation method is used – varies with the "hypnotizability" of the subject. James Braid (Neurypnology, 1943, p. 27) describes that "[a]fter ten or fifteen seconds have elapsed, by gently elevating the arms and legs, it will be found that the patient has a disposition to retain them in the situation in which they have been placed, if he is intensely affected", but then continues to describe how to proceed if the subject has not fallen into a trance after that period of time.