How could a chip like that work? How does it know when to cause him pain? It can't see who he's hurting, so it must be reading his thoughts. How can it do that? Maybe it can read the state of the neurons its next to. But that won't help unless all the relevant ones are concentrated in one place. From what we know of brains, they aren't. Maybe it somehow can scan the entire brain. If so, consider that this chip would work equally well if you just placed it next to someone's head: you could read their brain. So that's some pretty advanced technology, but Buffy does not take place in the future.
So suppose this chip can scan the whole brain. Will that help? Only if it can process all that data in real time (it causes the pain immediately). To process the amount of data in a brain, in real time, I think you'd need a computer about as powerful as ... a brain. But this chip is much smaller than a brain, including its high tech brain scanner. And our best computers aren't nearly as fast as our brains: they are around 500 times slower (source).
Another issue with the chip is: how does it cause pain? It could zap Spike's brain with electricity. But that would cause brain damage, which is never mentioned. It could hook into the brain and send brain signals which say Spike is in pain. Hooking into the brain so that it can send signals is pretty high tech itself. But worse, how can it know what signals to send? And if it can only send signals to a few neurons where its located, then will it always be able to send the necessary signals? We don't know exactly what it would take to calculate how to send pain signals, but if we expect they are like other thoughts, then constructing them would require comprehension of much of Spike's brain state. It would be a bit like trying to manipulate someone: you have to understand what sort of things they are thinking and feeling, and they figure out how to take advantage of those. It sounds like a task that requires creativity. So the chip would need (artificial) intelligence software. Alternatively, maybe there is a special part of the brain that causes pain when stimulated. If so, that may solve the pain-causing issue, but at the cost of locating the chip in a worse place for the purpose of reading Spike's thoughts.
On the show, we receive contradictory information about how the chip works. In one scene, Spike tries to punch Buffy a few times, but isn't hurt. He says that he knew she would dodge, and the chip only hurts him when he intends to hurt a human. So according to this, the chip must read Spike's thoughts, and reacts entirely based on them. This is roughly what we've been assuming above.
But in another scene, they are unsure whether a person is part demon. Spike punches her to find out: the chip hurts him, and everyone agrees this proves that she is human. But how is that possible? If the chip only knows what Spike knows, and works based on his intentions, then it can't be used to find out if someone is human. If Spike doesn't know, the chip doesn't know either.