I can answer only the question for basil.
If you wish to avoid flowering, the optimum light-cycle for basil is in the neighborhood of twelve hours. Research at the University of Minnesota has identified basil as a facultative long-day plant, that is long days, or more accurately short nights, encourage flowering. Short nights are, however, not required for flowering. For example, water stress (over or under watering) can often push basil into flower. Hence setting your artificial lighting to run for twelve hours daily will at least not encourage flowering. Also, make sure that you put the plants where they receive little stray light at night. A night that is interrupted by a bright light is interpreted by most plants as two short nights, and, in basil's case, this will push it to flower.
Since rosemary blooms in the spring, initiation of flowering likely to be more complicated. A mature rosemary will have buds ready to bloom as it heads into winter. Cool temperatures may be required for flowering, but day length (night length) may also play a part. I have not seen any research, and, when I have brought rosemary inside during the winter, it has bloomed.