- Peninei Halakha
We begin to count the omer on the night of the sixteenth of Nisan, as it says, "You shall count off seven weeks; start to count seven weeks from when the sickle is first put to the standing grain" (Devarim 16:9-10). "From when the sickle is first put to the standing grain" refers to the omer harvest, so called because the first harvest of the yearly produce is designated for the omer offering. The omer harvest took place on the night after the first day of Pesaĥ, which is the sixteenth of Nisan. As a result, that is when we begin to count the omer.
One must count at night, because the Torah says regarding sefirat ha-omer, "seven weeks; they must be complete" (Vayikra 23:15), meaning that the weeks must be whole. On the Hebrew calendar, a full day consists of night followed by day, so in order to include all the nights and days of seven complete weeks, we must start counting on the night of the sixteenth of Nisan (Menaĥot 66a). So that the count covers all the hours of the day, it is a mitzva to count early, at the beginning of the night. We are especially meticulous on the first night, so that the count will cover every hour of the seven weeks. Nonetheless, we enhance the mitzva by counting at the beginning of the night on every night, so that each day’s count will be whole, covering an entire 24-hour day.
Even though it is a mitzva to count at the beginning of the night, one is not obligated to do so. Therefore, one who is about to pray Ma’ariv must do so before sefirat ha-omer, due to the principle that more frequent mitzvot take precedence over less frequent ones. The mitzvot of reciting the Shema and praying Ma’ariv apply all year round, making them more frequent than sefirat ha-omer (Ĥok Ya’akov; see bhl 489:1, s.v. "aĥar").
 It seems that according to Rambam and Ran, it makes no difference when in the night one counts. However, the Sages say regarding all mitzvot, "The zealous perform mitzvot promptly." According to Tosafot and Rosh, it is better to count at the beginning of the night, because then the count is more complete. sa 489:1 rules that one should count at the beginning of the night. mb 489:2 and Kaf Ha-ĥayim 489:12 agree. Nevertheless, we pray Ma’ariv first, because the mitzvot of reciting the Shema and the Amida are more frequent (Ĥok Ya’akov). However, Mor U-ketzi’a maintains that one should count first, because the proper time for counting is the very beginning of the night, whereas Shema and the Amida can be delayed, le-khatĥila, for a half-hour. In practice, we count after Ma’ariv (bhl 489:1), because counting at the beginning of the night is not obligatory, merely a way of going above and beyond; as long as one counts at night, he fulfills the obligation of "temimot" (they must be complete). Therefore, we give precedence to Shema and the Amida, which are more frequent.
In order to avoid delaying the count, many poskim suggest that one count immediately after Kaddish Titkabel following the Amida, and before Aleinu, which is an additional prayer. This is found in mb 489:2 and Nehar Mitzrayim, and most follow this custom, including all Ashkenazim and those of North African descent. Nonetheless, many who follow Sephardi custom count after Aleinu, in order to first finish everything that is usually said in the Ma’ariv service.