In sailing days prior to steam engines, each ship leaving port would choose the ship's punk for that voyage. Women were not allowed on sailing ships in those days (as crew), but it was considered unhealthy to go too long without sexual release. Voyages often took weeks or months.
The ship's punk was chosen by lot, only the prior voyage's punk being exempt. Once chosen, that sailor's only duty was as cum bucket until the ship reached port again. He was to be available at any time for any crewman who desired to relieve his testicles of sperm build up. Generally, it was anal intercourse in such acts.
No particular emphasis on the title, though it was considered derogatory to be called the punk when it was not your turn. Since any man among the crew was in the lottery to become ship's punk, it was never wise to take insults or jokes about the punk too far. You never knew when the old punk was going to have a turn at the screwing the new punk.
To use the ship's punk did not make you homosexual in the modern sense. When in port, the majority of crewmen would happily make use of the prostitutes and women of the town. Considered a form of institutional/situational homosexuality only occurring during/in instances of enforced separation from women. It was also likely there were some bisexual and gay crewmen, just there are today.
The term 'punk' originates here, not with prisons, street slang, insult as an inferior male or with the music genre.
1) Captain: It's time for the lottery boys. Put your token in the bucket and I'll pick the new ship's punk.
2) Crewman: You're the ship's punk, so prepare to be boarded.