It's likely to be both the chain and cassette/freewheel need to be replaced. Depending on many factors, the chain can "stretch", and cause the sprokets to wear oddly. The odd wear interferes with the chain/cog interface and could cause the problems you describe.
As a quick check, measure the distance between the corresponding pins 12 links apart. Ideally, it should measure 12 inches. If it measures 12.125 (12 1/8) inches, then it's likely you'll need to replace both items. Some say a stretch beyond 12.0625 ( 12 1/16) inches is too much.
Start with this measurement and post the results.
Also, does this problem occur in all gears, or just certain combinations?