[野菜]{やさい}を食べます。 vs 野菜は食べます。
Grammatically speaking, both are correct. They're different in meaning and usage.
を is the object marker. 野菜を食べます is usually an unmarked statement to say "I eat/someone eats vegetables". The は can be, roughly speaking, the topic particle (主題の「は」) or the contrastive particle (対比の「は」). For example, you can use them this way:
「普段、朝食に何を食べますか?」--「野菜を食べます。」(not は)
"What do you usually have for breakfast?" -- "I have vegetables."
「鈴虫は何を食べますか?」--「ナスやキュウリなどの野菜を食べます。」(not は)
"What do bell crickets eat?" -- "They eat vegetables such as aubergine and cucumber."
Here, the を marks new information (新情報).
「普段、野菜は食べますか?」--「はい、野菜はたくさん食べます。」(not を)
"Do you eat vegetables regularly?" -- "Yes, (lit. As for vegetables, I eat a lot. →) I eat a lot of vegetables."
The は is the so-called "topical/thematic は". Here, it marks old/known information (旧情報/既知情報).
は can also be used this way:
「野菜は食べます。でも肉は食べません。」
"I eat vegetables. But I don't eat meat."
「鈴虫は*、肉は食べませんが、野菜は食べます。」
"Bell crickets don't eat meat, but they eat vegetables."
*The は in 鈴虫は is a topic marker; there can be only one topical は in a clause. If you see two は's in one clause, at least one of them should be contrastive.
The は here is the so-called "contrastive は". (You could refer to this thread for more about the contrastive は: What's the difference between wa (は) and ga (が)?)
肉は食べません。 vs 肉を食べません。
Again, they're both grammatically correct, and different in meaning
and usage.
The は can be topical/thematic:
「お肉はよく召し上がりますか?」--「いいえ、肉はまったく食べません。」(not を)
"Do you eat meat often?" -- "No, I don't eat meat at all."
The contrastive は is also used to mark or highlight the negated element in a sentence:
普段、朝食に肉は食べません。
I usually don't have meat for breakfast (can imply: but I have something else).
普段、朝食には肉を食べません。
I usually don't have meat for breakfast (can imply: but I do for dinner).
普段は、朝食に肉を食べません。
I usually don't have meat for breakfast (can imply: but I do today).
Here, the は shows the scope of negation: 肉を* is negated in the first sentence, and 朝食に is negated in the second, and so on.
* When 「XXを」 or 「XXが」 is marked with a は, the は replaces the が or を,
as in 「XXは」 rather than 「XXをは」「XXがは」.
There usually is some negated element in a negative sentence, and therefore you'll more frequently see a は in a negative sentence.
As for the example using an を, you'd use it in a context like this:
「子どもの好き嫌いが激しくて…。」--「何を食べてくれないんですか?」--「野菜をぜんぜん食べないんです。」(not は)
"My child is so picky about food..." -- "What does s/he not eat?" -- "S/he doesn't eat vegetables at all."
You'd reply with 「~を」「~が」「~に」「~と」「~から」 etc., not 「~は」「~には」「~とは」「~からは」 etc. to questions 「何を」「何が」「どこに」「誰と」 etc., as in: 「何がないんですか?」「消しゴムがないんです。」(not は) / 「誰と連絡がつかないんですか?」「山田さんと連絡がつかないんです。」(not とは)
always
<-- Naw. The は's in these examples do NOT indicate subject/theme/topic: 「普段はいい子なのに・・・」「10万円はするぞ!」「私は、電気は嫌いです。(by バーサ in 魔女宅. There can't be two topics in one clause)」