On a diesel engine, how can I know which glow plugs are defective, and can I change these only?
A glow plug is essentially a resister and is tested the same way:
Yes, it is okay to only replace the bad ones. However, if it's a high mileage engine, you may be back under the hood in a week replacing another bad plug. It's up to you to decide on cost vs labor in this situation. A lot of that depends on how hard it is to gain access to the plugs.
Be sure to test the new plugs before installing them.
Everything S_Niles says is correct, but you can save yourself some hassle by checking the resistance before you remove the glowplug(s) from the engine blocks, by touching one end of your ohm meter to the end of the glowplug (after removing the wire/harness from the glowplug), and the other to your engine block. Do this to all of your glowplugs. The glowplug(s) that show greater resistance are bad. Typically, 3 will read (nearly) identical resistance, and the 4th will show much greater resistance (on a 4-cyl engine, of course), and assuming one of the plugs is bad.
Of course this method is far less precise than that described by S_Niles--you could well get higher resistance readings this way. But they key is to look for one plug that has higher resistance than the others.
This method I have used on my 4-cyl TDI engine.
I have always replaced all 4 plugs at once, as (at least for my engine), the parts are inexpensive.