Referring to the historical forfeit or seizure of one's farm due to loss of income or inability to pay costs, this expression means one has lost a great deal of money gambling.
Megan: "Hey Joe! How'd the poker tournament go?
Joe: "I lost the farm."
Chris: Hey Sarah, I'm going to the racetrack to bet on horses.
Sarah: Don't lose the farm!