Postgresql, escape character in string_agg function
The doubled double-quotes ("") are the necessary consequence of " being the default quote character for COPY with CSV format. The manual:


  QUOTE
  
  Specifies the quoting character to be used when a data value is quoted. The default is double-quote. This must be a single one-byte character. This option is allowed only when using CSV format.
  
  ESCAPE
  
  Specifies the character that should appear before a data character that matches the QUOTE value. The default is the same as the QUOTE
  value (so that the quoting character is doubled if it appears in the
  data). This must be a single one-byte character. This option is
  allowed only when using CSV format.


You could use something like (assuming Postgres 9.1 or later):

COPY (...) TO stdout (FORMAT CSV, QUOTE '\');


Then double-quotes are not escaped.

To ...


  add escape character \ just for fields param_name and value


.. you could simply replace():

string_agg(distinct '{name:"' || replace(param_name, '"', '\"') || '",value:"' || replace(value, '"', '\"') || '"}',',') as "params"


Or:

string_agg(distinct format('{name:"%s",value:"%s"}', replace(param_name, '"', '\"'), replace(value, '"', '\"'), ',') as "params"


But string_agg() has nothing to do with either. And I am not sure what you are trying to achieve.