If I would write:
char *a=malloc(sizeof(char)*4);
a=\"abc\";
char *b=\"abc\";
do I need to free this memory, or is it done by my system?
Simple answer yes,no. Also your code is buggy.
Concrete answer:
char *a=malloc(sizeof(char)*4);
You allocate memory so you should free it.
a="abc";
This assigns a pointer to a constant string to your char* a, by doing so you loose the pointer to the memory allocated in the first line, you should never free constant strings.
Use strcpy(a,"abc"); instead of a="abc"; to move the string into your allocated memory.