One of the math professors at my university gave a talk on this very subject. He didn't go into the infinite case, though.
Here's the solution for the finite case. Basically, since the hats are Black and White we can number them 0 and 1, respectively. Thus, if there were six people in line, the back person of the line would add up the numerical value of all the hats in front of him mod 2. He then calls out that number. The person in front of him, person 2, would add up the values in front of him and doing some arithmetic would know the color of his hat AND the color of the person's hat behind him.
Person 3, however, has to keep track of both numbers called out do some arithmetic, figure out the color of his hat and call out the correct color of his hat, also. So on and so forth.
This method will guarantee that 5 out of the 6 people go free. The person in back has a 50% chance of going free.
Can I extend this to the infinite case? I think so.
I believe that the infinite case is still solvable, and there has to be another piece of information given out. Let's also assume that since there are a countably infinite number of people, there is a one-to-one relationship from the number of people to the natural numbers. The person in the back of the line is person 1, the person in front of him is person 2, the person in front of person 2 is person 3, and so forth.
Also, let Black hats correspond to the number 0, and let White hats correspond to the number 1, again as in the finite case. Since the people are allowed to discuss a strategy before hand, they decide to stick with modular arithmetic as in the finite case. However, here is where they must decide on something.
In the finite case, we had a stopping point, namely the end of the line. However, in the infinite case, no such end of the line exists. Therefore the people have to decide on an arbitrarily large number 'N' that person 1, person N+1, person 2N+1, person 3N+1, and so forth will be the start of a "new" line, so to speak. So you have an infinite number of lines the original is broken up into. There is only a finite number of people in each new line so the finite case applies to each new line. Thus you have a countably infinite M number of people that had a 50% choice of being either correct or incorrect, so M/2 is the expected number of people that get it correct. So, really you only have at most M/2 being incorrect.
But, M/2 is an infinite number, so it doesn't help us. Hopefully, I'm on the right track, and someone can fix this.