I will go to a resturant for pie.
There is nothing wrong with this sentence. I imagine the speaker will soon be seated in a restaurant, ordering a slice of pie.
However:
I will go to a resturant to eat a pie.
This is the version that would make me look surprised. When you "eat a pie", that typically means you eat the whole pie.
The same could be said for cake: "eat cake" means "eat some cake", but "eat a cake" means "eat the entire cake."
We don't usually use the word "a" unless a person eats the whole thing as a single unit (in this context, "a" means "one"):
I went to the restaurant and ate a sandwich.
I went to the restaurant and ate a gyro.
I went to the restaurant and ate a salad.
or unless we specify the unit somehow:
I went to the restaurant and ate a bowl of soup.
I went to the restaurant and ate a piece of pie.
I went to the restaurant and ate a rack of ribs.
I went to the restaurant and drank a glass of wine.
But no article is used when there is an unspecified amount of food (the lack of the word "a" means "some"):
When I get to the restaurant, I'll order scrambled eggs.
When I get to the restaurant, I'll order spaghetti.
When I get to the restaurant, I'll order shrimp.
When I get to the restaurant, I'll order pie for dessert.
When I get to the restaurant, I'll get coffee.
Here's something a bit more advanced: The word "the" can be used when referring to a particular restaurant's version of a dish.
What would you like today, sir?
I'll have the veal saltimbocca.