As stated as a comment, the formula for barium fluoride is #BaF_2#. Barium is an alkaline earth metal (group 2). Alkaline earth metals can give up two electrons to complete their octet. Fluorine is a halogen (group 17). Halogens need one electron to complete their octet.
Now that we have this information, we can find the chemical formula. Barium has two electrons to give up. Fluorine needs one. If we were to combine one barium and fluorine, the chemical formula would be #BaF^+#. Unless otherwise stated, chemical formulas will be neutral. In order to make this a neutral compound, you need to add one more fluorine to the compound to get #BaF_2#. Now the compound is neutral. Barium gives each of its two electrons to each fluorine.