If one is unable to ejaculate sufficient sperm, such as in cases of infertility involving low sperm count, or when a vasectomy or other obstruction prevents semen from getting expelled from the testes, indeed, a needle is used in a procedure called testicular sperm extraction (TESE). It is painful, and only something done as a last resort.
Unless one were conducting a clinical trial on infertile patients who would require this, that would not be the method of obtaining sperm.
I have my doubts that someone would be able to obtain IRB approval to study sperm in pubertal boys, due to the obvious social issues of the collection process.