Sex can lead us to suffering in many ways; however, if all of us are just like Lord Buddha according to his story, wouldn't humanity become extinct?
Sex is prohibited for monks and nuns
If you are not observing higher precept like 8 or 10 precepts sex is not prohibited for lay person. Lay person has only to adhere to 5 Precepts. This prohibits wrongful sexual acts, i.e., sex with someone under another's protection... and other acts.
As you said sex is craving and can lead to suffering. But not very body or householder is in the stage to eradicate higher stages of craving for sensual pleasure than the rudimentary level which might lead to misconduct. At the basic level this is what is required. As you progress in the path you have to remove sexual urge.
Also Vipassana Meditation can help reduce sexual urge. There are Samatha techniques also but if you take the insight root you kill 2 birds with one stone. You can try http://dhamma.org or http://internationalmeditationcentre.org which has centres in many cities and faily large outreach.
You loose complete sensual desire is when you become a non-returner where by you eliminate the fetter of sexual desire. If you take human world number of being achieving this state is small. Hence there is no risk of extinction. Also a stream enter will have lust and a lay follower may engage in sex as long as it is lawful (a stream enter does not engage in sexual misconduct).
So the real question is what a person needs. It's either the continuance of the Human Race or being free from personal Suffering. Before anything else let's look at what Lord Buddha said about Humans.
Lord Buddha said that there is only one Human realm. But Lord Buddha never said that there is only one Human world. People often misunderstand Earth for the world realm. According to Buddhism there are numerous planets like earth which includes Humans in them. Some experts suggest that Lord Buddha means Parallel worlds, but that is not up to us to decide. So even if a disaster kills all of us here it would not be the end of the human race.
Is sex forbidden?
The simple answer is NO. But if someone wants to take and advanced step while living a Lay person's life he or she can refrain from SEX. So it is a personal choice not a necessity or mandatory.
But we as Buddhists consider sex as a low and worldly joy, As what we seek is a much better one.
A Buddhist does not need the continuance of the world, A Buddhist has one goal and that is Nirvana. But Lord Buddha directly said that Buddhism is only for the wise and others will not understand. So we as Buddhists do not share that view a lot of religions have of a world with only one religion.
We know that there will always be a huge amount of people who are not Buddhists and we will always be outnumbered. Lord Buddha taught this as a nature of beings. So there will never be a chance of Humans race meeting it's end because of Buddhism.
In most Buddhists cosmologies worlds and civilizations come and go... Whole worlds go extinct. Hell Realms come and go... as do biological species... buildings... yada yada... Heaven Realms... human and animal lives, the whole nine yards.
This process is larger than a lifetime though in scale, worlds of beings raise and fall out of existence, our lifetimes do not extend the duration required for observing these events.
All that being said, sex in itself is not an inherently bad thing. You are correct that if sex was never engaged in humanity would go extinct. Since all current medical technology can't end age...
As pointed out in the other answer it is certain behaviors that are to be avoided for lay people concerned about karma. The majority of these things involve things like consent, respect.
Sex is an outcome of heat - one of the four elements which this world is made of. If there is no body heat, body dies. Therefore its wrong to say that enlightened ones cannot have sex. In fact in majority of all major religions prophets were married and had children. Prophet Moses was married. Prophet Mohammed was married. Ram and Krishna of Hinduism were married.
But yes they never hankered for it. It is the need of the others they were fulfilling not their own needs. The pleasure enlightened ones get in sex is nothing compared to bliss of Nirvana.
Until and unless one is enlightened sex will play a dominant role in one's life. Some honest ones will acknowledge it and others will be evasive of it. In India there was a practise in the past to see if one has transcended sex. People will feed the person who claims enlightenment to heart's content with food which is laced with aphrodisiac (Viagra kind of substances). After that a prostitute will be sent to his chamber in night to seduce him. If somebody claims that he has transcended sex I suggest to use this technique on himself. Ofcourse this technique is only for men but this works and takes away delusions. And this technique is religion independent.