I want to know that if someone had eaten food cooked by kafir then will his good deeds be accepted? I have heard somewhere that for 40 days his namaz and all deeds are not accepted. Then what if after eating that food he feels sorry and as he is going for ziyarat of imam Hussain (as) at karbala will his this act accepted?

Can you define what you are meaning by Kafir. Do you mean an Atheist? If so did he prepare haram meat? If the Meat was halal did he touch it with bare skin or was he wearing gloves?