"If" with implicit "then" question: Should a comma be used?
In that case, the comma is optional. According to the Wikipedia page on comma:
In English, a comma is generally used to separate a dependent clause from the independent clause if the dependent clause comes first: After I brushed the cat, I lint-rollered my clothes. (Compare I lint-rollered my clothes after I brushed the cat.)
[…]
While many style guides call for commas, many authors omit them, particularly with short sentences.
The two paragraphs that I extracted from the article apply to your sentence. It’s a short sentence with a dependent clause (if the item is an apple) and an independent clause (it should be given to children), where the dependent clause comes first.