It occurs to me there are no less than FOUR distinct changes of P to F in Near Eastern languages, bearing on this.

Original Semitic P changed to F in old Arabic (i.e. pre-Quranic). So Falastin, Farsi, corresponding to the European names Palestine, Persian (which come to us via Greek & Latin).

Post-classical Greek PH (aspirated P) changed to F: this happened a century or so after the New Testament period, it appears. This is why the letter phi now represents an F sound in Modern Greek.

However, this happened after words containing photo-, graph- etc were borrowed into Latin, so Latin retained the original aspirated P sound, and it was this that was carried forward into Middle English and Middle French. I believe (I can't swear to this) that the F pronunciation of Modern Greek was only introduced to the West after scholars fled the fall of Constantinople, or at least shortly before that when Byzantine scholars came to the West and re-established the study of Greek. (The first chair of Greek was established in Italy in the 1300s, I think.)

Finally, P changed to F in ancient Hebrew in some positions: at the ends of words, and when single between vowels. So the letters kap and qop came to be pronounced kaf and qof. (They are usually written kaph and qoph.) The word nepesh 'soul' came to be nefesh. It is not clear (at least not to me) when this change took place, how early in the Biblical period. The much later Tiberian system of punctuation shows it was in place before the year 500, and if oral tradition was accurately transmitted (Hebrew having by then been a "dead" language for a long time), then the contrast could well have been in place in the living Biblical Hebrew language. The consonant script doesn't show it, but doesn't need to.

It is believed that P in other positions (where it remained P in later Hebrew) was aspirated. So the Greeks heard the Hebrew words like par`o as Pharao rather than Parao. (This was before the unrelated PH > F change in Greek.) The P of Pharoah, Philistine/Palestine , having been borrowed into Greek, some centuries later changed into F just like native Greek words like photo-.

As far as I'm aware, the Hebrew and Arabic changed are unrelated to each other.

The Greek and Hebrew parts of this story also apply similarly to the groups we write CH and TH.