What is it to fear The Lord? How and when do we fear Hashem?
There are many verses in The Torah that talk about fearing the Lord.
What do the Rabbis and the Talmud say about the question? Is there a general answer to this question?
The Rambam, positive commandment #4, codifies the mitzvah to fear Hashem. Aside from the "secondary" application of not saying Hashem's name, the manifestation of the mitzvah is to expect ramifications for your actions:
המצווה הרביעית היא הציווי שנצטווינו להאמין ביראתו יתעלה ובמוראו, ובל נהיה שאננים ובוטחים - אלא (נחכה) [ונחוש] לביאת עונשו ית' בכל-עת. וזהו אמרו יתעלה: "את-ה' אלוקיך תירא
In terms of when you should do it, the Rambam says "בכל עת", at every moment.
The Zohar on Breishit, page 11b, gives this general definition:
יראה דאיהי עיקרא, למדחל בר נש למאריה בגין דאיהו רב ושליט עיקרא ושרשא דכל עלמין, וכלא קמיה כלא חשיבין
The fear that is the main thing is: for a person to fear his lord because he is lord, and rules, and is the essence and the root of all the worlds, before whom all things are as if they don't exist.
there are two levels of fear.
fear of punishment. this comes through contemplating the consequences of your actions, ie reward and punishment as explained throughout the torah such as in the shema. this also applies when a test comes before a person as the chafetz chaim writes in the sefer hamitzvot on the mitzva of fearing God "a person is then obligated to arouse fear of God...", ie in order to vanquish bad temptations.
fear of the greatness of God - this comes through knowing God. the more one knows God, ie His wisdom, power, and ability, the more He will be in awe of Him and be moved to serve Him wholeheartedly on his own understanding. A good source for this is in the Chovos Halevavos especially the first 3 gates.
Yirat shamayim means that you are able to base real decisions on the structural reality of the Torah.
For example the gemara in Gitin 56 relates that when Raban Yochanan escaped Jerusalem and was given an audience with the Roman general beseiging the city he addressed him as the king based on a derasha that the Bet ha'Mikdash would only fall at the hands of a king.
Rabbi Wolbe points out that Raban Yochanan was prepared to bet his approach in a murderous political situation on a derasha, and in the end he was proven correct.
His perception of reality through the Torah surpassed his perception of reality through his senses.