Sperm cells which are the male gametes (sex cells), are produced in the testes or male sex organs (gonads). The special process that produces the male sperm cells is called spermatogenesis and it is accomplished by meiosis.
Cells of the body are called somatic cells and contain the diploid amount of chromosomes represented by 2n. For humans, the 2n amount is 46 chromosomes, or 23 pairs. Cells inside the testes have the diploid or 2n chromosome number because they are somatic cells. These diploid cells called primary spermatocytes undergo meiotic cell division eventually forming haploid sperm cells.
Meiosis is known as a reduction division. This cell division has two stages--meiosis I and II which eventually produces four haploid gametes or sperm cells from cells in the testis that undergo meiosis. Therefore, sperm cells will have 23 chromosomes which is the haploid amount of chromosomes in humans.
Males produce sperm cells from the time of puberty and throughout their lives. After fertilization -- the process by which a sperm nucleus fuses with an egg nucleus, the genes from each parent will be present in the newly created, diploid zygote. The processes of meiosis which creates haploid gametes (sperm and eggs) and fertilization which forms a diploid zygote make up the life cycle of humans.
I have included a diagram of spermatogenesis and another link to a detailed explanation of meiosis.