This depends on the type of filling you get. Amalgam fillings can take longer to harden, so you may need to avoid solid foods for a day. Your dentist will give you instructions on taking care of your amalgam filling to ensure the best results.
Composite fillings harden quicker with the help of a blue UV light. You’ll likely notice your dentist using this light after placing the filling. You can usually eat very soon after your filling is placed, sometimes immediately after.