The Torah in the Book of Shemot (13:2) establishes the Halacha that a male firstborn of a Kosher animal – known as "Bechor Beheima Tehora" – has a status of Kedusha (sanctity), whereby it is designated as a sacrifice. Therefore, it is forbidden according to Torah law to slaughter a Bechor, as this would constitute slaughtering a sacrificial animal outside the area of the Beit Ha'mikdash. It is similarly forbidden to partake of the meat of a Bechor, in light of the prohibition against eating sacrificial meat outside the city of Jerusalem. Both these prohibitions are particularly severe, rendering one liable to Karet (eternal excision). The Rambam (Spain-Egypt, 1135-1204) rules in Hilchot Bechorot (1:5) that these laws apply in all locations, even outside the Land of Israel.
So how do we deal with this issue today? What should we do in today’s times to prevent transgression of this prohibition?
People who breed Kosher animals have two options for avoiding this prohibition. First, they can wait for the firstborn animal to develop a permanent physical blemish, which divests the animal of its status of Halachic sanctity. More commonly, however, Jewish ranchers sell to a gentile their adult female animals that have yet to give birth, so that the firstborn animals will be born under the ownership of a gentile. The Torah explicitly limits the Halacha of "Bechor Beheima Tehora" to Jewishly-owned animals, and thus this status does not apply to the firstborn of an animal owned by a non-Jew. Alternatively, a Jewish rancher can establish a partnership with a gentile, such that they co-own the animal. Since the gentile is a part-owner of the animal, its firstborn does not obtain the status of "Bechor Beheima Tehora."
The Rishonim (Medieval Talmud scholars) disagree as to how the sale of a mother animal must be performed. Rashi (classic Biblical and Talmudic commentator, France, 1040-1105) requires transferring money for the sale to be effective, whereas Tosefot (commentary to the Talmud by students of the Tosafist schools of Medieval Europe) requires the transfer of a Shetar (legal document affirming the sale). Yet a third opinion demands selling even the ground upon which the animal is situated. The practice today is to satisfy all views by performing the transaction through all the means mentioned above. The Ben Ish Chai (Rabbi Yosef Chayim of Baghdad, 1833-1909), in Parashat Tazria, and Chacham Ovadia Yosef, in Halichot Olam (vol. 5, p. 287), emphasized the point that the mother animal itself must be sold to a gentile, and not the fetus. Halacha does not allow for selling a "Davar She'lo Ba Le'olam," an object that one does not yet own, such as something that has yet to come into existence. This would include the sale of an unborn fetus, which has yet to enter the world. Therefore, the sale of a mother animal for the purpose of avoiding the prohibition of Bechor must be overseen by a competent Halachic authority who is familiar with the many intricacies involved in this transaction.
Summary: One may neither slaughter nor eat meat from a firstborn male Kosher animal. One can avoid this prohibition by either waiting for the animal to develop a permanent physical blemish, or, as is more commonly done, by selling to a gentile one's female animals that have yet to give birth, so that the firstborn animals are born under the ownership of a gentile.