Below you see the chocolate bar I made. The method I used is that, I created a cube, made its size as rectangle and extrude top a little, resize then extrude again. And there was one part of chocolate bar. After that I duplicated it and joined them together to made the final chocolate bar. But is there a way to duplicate the action I do on one face when I work on subdivision? That would make this kind of work so much easier.
I'm not sure I understand your question 100% correctly. So forgive me if I answer not what've asked.
Straight to "is there a way to duplicate the action...?"
⇧ ShiftR is your friend when you've just done something good to a face (edge, vert, multiple selection...) and would like to do the same to others. Just select the next part and hit the shortcut. Big time-saver indeed.
And as the topic suggests let me give you my advice on actual chocolate bar design (who can stand tempted with chocolate :-)).
As suggested by m.ardito you could go with arrays too.
But my favourite for this kind of models is cube-modelling + edge-loops + inset faces. Very quick, in fact.
Don't forget to choose Individual for Inset faces and play with Depth (hold Ctrl). Then adjust by scaling on separate axes with Individual origins as pivots.
With this I really wanted to demonstrate that you don't necessarily need to repeat some action if your model is by-nature very homogenous.