Yes you have allocated 32 chars for ch pointer. But right on the next line you're reassigning another statically allocated string to it which overrides the pointer to the dynamic memory that was stored in ch.
ch = (char *)malloc(sizeof(char)*32);
ch = "hello";
The result of this is, you lose the handle to the dynamic memory and now you have no way of freeing that memory with free().
If you want to assign "hello" to ch, you can do it with the strcpy function define in <string.h>.
#include <stdio.h>
#include <string.h>
int main()
{
char *ch;
ch = (char *)malloc(sizeof(char)*32);
// ch = "hello";
strcpy(ch, "hello");
ch[5] = 'k';
ch[6] = '\0';
printf("%s", ch);
free(ch);
return 0;
}
Strcpy just iterates through the array and assigns every character one by one. Also never forget to free the dynamic memory allocated.