If I have a circuit the have two parts and they are isolated by optocoupler.(both power and data isolated).Is it necessary to add a 1nf 1000V capacitor between two ground? is there any need to add protection device?
If the only connection is optical you should consider them totally independent circuits and do things to them separately. The closest they should be connected is in the case of a common power supply where they both have wires running back to the supply terminals.
The two circuits should be safety grounded separately.
I was making some assumption about your circuits. In general they have to comply with the safety laws. If this product is battery powered there is no safety ground requirement. If it is AC mains powered there is the requirement. If they are in the same box just one safety ground connection is required.
1) What is meant is circuit before and after optocoupler should be considered as separate circuits. And each behaves independent of the other. No ground should be made common between them.