Q:

Why is India still using the penal codes drafted by the British for punishments?

India is still using the Indian Penal Code, drafted in 1860, written by the British.
Since India already gained their own independence, why can't they write their own penal codes?

A:

This is an interesting question and I think it deserved an answer.
According to Wikipedia we find out that:

Its basis is the law of England freed from superfluities,
  technicalities and local peculiarities. Elements were also derived
  from the Napoleonic Code and from Edward Livingston's Louisiana Civil
  Code of 1825.

Also we can see that numerous (about 40) amendments (improvements) were performed before Indian Independence Act (1947).
So, Indian Penal Code is a solid set of laws that had much time to become mature even before 1947. 
Changing Penal Codes within a democracy is far from being trivial and it might incur great cost:

changes must be debated among various actors within the society such as lawyers, judges, law makers etc.
changes must be disseminated to all the people, but especially to law enforcers, judges, lawyers. This takes time and costs money

A quite notorious example of how hard it is to change criminal laws is Canada (1, 2) which has some "zombie laws" (inapplicable anachronistic laws):

Outdated offences that are still included in Canada’s Criminal Code
  include dueling, abortion and pretending to practice witchcraft

Using old law codes is not something strange. E.g. The Napoleonic Code is still used today in some countries:

The resulting code is the basis of the modern so-called "inquisitorial
  system" of criminal courts, used in France and many civil law
  countries, though significantly changed since Bonaparte's day
  (especially with regard to the expansion of the rights of the
  defendant).

Using such old codes as basis for current laws is somehow counter-intuitive, especially for people within IT industry (modern means better). However, criminal codes deal with problems that changed very slowly during human evolution (murder, theft, rape exist for millennia). Also, their relative harm effect is quite constant (e.g. murder is worse than theft).
Conclusion: from the practical point of view, penal code rewriting is very hard to achieve, so the "if ain't broken, don't fix it" principle applies.

