A slice is always a piece, but a piece is not always a slice.
In general, a slice is a portion created with a single cut, and either it is wedge-shaped, or it is relatively thin in one of its dimensions because it is a cross-sectional cut of a much longer object; while a piece is a portion created by any means at all (cutting, tearing, shattering, biting, etc.), and of any shape or size.
So if you are dividing up a poundcake (which is shaped like a small loaf of bread), you will often get a slice of it; but if you are dividing up a sheetcake (a large, flat, rectangular cake; commonly used for birthdays), you will get a piece of it.
Likewise, you can get a slice of pie (after the first piece, every subsequent piece is created with just a single cut) or pizza. (Unless you're at one of those crazy places where they cut pizza into squares, in which case you are getting a piece, not a slice.)
Oddly enough, a slice of cheese almost always refers to a flat piece; if you are taking a pie-shaped piece of cheese from a wheel, it will be called a wedge.