It would be something like this:
avrdude -c usbtiny -p m328p -U lock:w:0xFC:m
You could do that via the SPI interface using a USBtinyISP or similar programmer.
Be warned that after doing this you can only ever change the chip again by using a high-voltage programmer like the AVR Dragon. So if you don't have one of those to hand you have now made your chip un-programmable. Better do that when you are really confident it is right.
Is there a way to protect my code when I use only Arduino board and Arduino IDE? Can I set the lock bits from the program that I upload into the processor?
No, I don't think the bootloader has that capability.
The USBtinyISP (kit) costs $22 from Adafruit:
This is a kit, you have to assemble it.
The AVR Dragon costs $50.96 from Digi-Key.
Be warned that to use the Dragon you have to do a fair bit of jumpering of pins because it is designed for lots of different processors.
Personally I wouldn't bother. Unless you are doing production runs of lots of processors it is hardly worth the effort. If it is just for you, you need the extra expense and trouble of being able to reprogram with one of these devices.
For your customers, if you have them, they can no longer field-reprogram them, so if you find a bug they would have to be returned to you. And if the processor is soldered onto the board you will have a lot of trouble using the high-voltage programming.