Please note that gender is not the same as sex.
With regards to your actual question, how is gender decided for new words?", I can't answer definitively for French (as I'm not a native speaker) but I can make some educated guesses based upon what I know of French, what I know of language evolution and how this goes in my own native language, which is gendered as well.
I assume it is like with any evolution of language, a combination of usage and formal or informal rules (which are themselves derived from usage).
Ie, people start using a certain word and to use it they have to assign it a gender. They choose this gender based on any number of reasons (similar words, the way it sounds, the ending of the word, its meaning, ...). If enough people use a certain gender it gets recognized and added to the dictionary with that gender.
Drawing from my native language, Dutch, there have evolved a few rules-of-thumb for guessing the gender of words, which can be applied to new words. If the new word is a barbarism (an import from another language, such as English) there might be a number of rules specifically for handling such words.
Examples of such rules in Dutch are:
- words that describe abstract concepts are usually feminine, words that
describe concrete objects usually masculine. (Thus "universiteit"
(university) is both feminine and masculine, depending on whether you mean
the institution or the building).
- anglicisms (barbarisms from
English) are usually masculine or feminine, unless specific rules apply. For
example, words ending on -ism or -asm in English are usually neuter.