I tested the latest DOSLIB code, here are my findings:
If you write port 43h then the counter, the counter loads the new value right away and begins counting down.
If you do NOT write port 43h, then write the counter, the new value takes effect only when the current value is finished.
This is very likely consistent across all three timers, not just the PC speaker, and very likely consistent across at least mode 2 and 3.
It's interesting to note that DOSBox-X and SVN both acknowledge this somewhat with the "new_mode" variable per-PIT in timer.cpp, though this behavior is only accurately emulated for PIT 0 (timer) in mode 2 at this time (with a comment mentioning DoWhackaDo).
DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.