As JohnLandsberg says, this is a problem that has been much discussed among English-speakers for many years.
If you are referring to a specific person, that person is presumably either male and female and this should not be a problem.
Likewise if in context the person must be male or must be female, there should be no problem. In your first example, I would think that when this woman talks about falling in love with the first person to pop a head up, she is likely thinking the first man to pop his head up. Unless she is a lesbian, in which case it would be the first woman. The only way this example would be a problem is if the woman really means that she could fall in love with either a man or with another woman.
But assuming neither of those cases apply:
(1) The old rule was, When the person referred to could be either male or female, use "he". So you would say, for example, "Ask the applicant if he will please fill out the form", etc., even if "the applicant" could be either a man or a woman. But some number of people find this insulting to women. In some cases it might create a real ambiguity whether the intended meaning is that the person must be male, or if it could be either male or female.
Alternatives that have been suggested include:
(2) Make up a new word that can refer to either gender. Nice idea, but inventing a new word and getting large numbers of people to use it is hard. You can pull it off if, for example, you've just invented some new gadget and have to give it a name, because there was no word for it before and people have to call it something. But we already have personal pronouns, and what's more, you often find yourself using pronouns several times in a sentence, likely hundreds or thousands of times in an article or a book. That many occurrences of a made-up new word is very distracting. So this idea has largely gone nowhere.
(3) Use "he/she", "him/her", etc. This works, but it is very awkward to read and gets tiring after a few uses.
I use this when I want to make clear that the person referred to could be of either sex. Otherwise I, and, I think, most writers, generally avoid it.
(4) Recast the sentence to use plurals. In English "they", "their", and "them" have no gender and so avoid the "sexism" problem. Instead of saying, for example, "Give a customer his receipt", say, "Give the customers their receipts". The problem with this is that sometimes we are talking about only one person. Like, "The winner of the contest is the contestant who earns the most points. He can earn points by ..." We cannot just change this to, "The winners of the contest are the contestants who earn the most points. They can earn points by ..." The first sentence says that there is one winner. The second sentence says that there are many winners. I've seen some discussions of cases where this is not obviously wrong but introduces a subtle change in meaning. One writer gave an example of "The citizen must work to defend his nation's principles ..." being rewritten as "Citizens must work to defend their nation's principles ..." He argued that this was similar, but not the same: The first indicated an individual responsibility and individual action, while the second implied group responsibility and collective action.
Personally, I often do this when it does not hurt the meaning to use plurals.
(5) Use plural pronouns but singular nouns. So some people will write things like, "When the customer requests a receipt, give them their receipt." That is, we say "the customer", singular, and "receipt", singular, but use "them" and "their" for the customer. Others object that this violates a very basic rule of English grammar that a pronoun must agree with its antecedent, i.e. you shouldn't refer to a single individual as "they". Aside from the arguably pedantic issue of obeying a rule because it's a rule, in some cases this could be confusing or ambiguous. Like #4, it might lead the reader to believe that many people are doing something when only one person is doing it.
(6) Mix use of masculine and feminine. This is becoming increasingly popular today. Someone writing an article in which he gives four examples of hypothetical people doing whatever will use masculine pronouns for two of the examples and feminine pronouns for the other two. I've seen some cases where a writer will mix pronouns referring to what would seem to be the same person. Like he'll say, "When the customer enters the store, greet him at the door. Ask her what she is looking for." I find this very distracting. But to make the first customer a "he" and the second a "she" makes sense.
(7) Use the opposite pronoun from what one would expect. Like say "The auto mechanic ... she ..." and "The nurse ... he ...". Personally I find this annoying and silly. In real life, the vast majority of auto mechanics are male. If you think that more women should enter this field, well, go ahead and work to make that happen, but just pretending that there are lots of female auto mechanics when there aren't ... I don't see the point.
(8) Avoid using pronouns: use a noun instead. Like instead of saying, "When the customer enters the store, greet that person. Ask what the customer wants." The catch to this is that you either, (a) End up using the same noun over and over. "Give the customer the customer's receipt, then tell the customer that the customer's warranty will apply to the product that the customer bought ...". This sounds very wordy and awkward. Or (b) you use different nouns to refer to the same person. "Give the customer the person's receipt, then tell the purchaser that the buyer's warranty will apply to the product that the visitor bought ..." This can leave the reader confused whether you're talking about the same person or different people. In my humble opinion, it is almost impossible to replace all pronouns with nouns without making the text hopelessly awkward, and unless you do it 100% of the time, you haven't solved the problem.
Personally, I often use plurals in informal speech and writing when it doesn't create an ambiguity. In more formal context, I use the old default-masculine rule unless it would create confusion.
Sorry for the long answer.